#include <fstream>
using namespace std;
const int MAXN = 1e5;
ifstream cin("disjoint.in");
ofstream cout("disjoint.out");
struct DisjointSet{
int p[MAXN+1]; // parent element
int r[MAXN+1]; // size of elements in subset i
int n; // number of elements in the set
};
DisjointSet init_ds(int n) {
DisjointSet ds;
ds.n = n;
for (int i = 1; i <= n; ++ i) {
ds.p[i] = i;
ds.r[i] = 1;
}
return ds;
}
int find(DisjointSet& ds, int node){
if (ds.p[node] == node)
return node;
else{
ds.p[node] = find(ds, ds.p[node]);
return ds.p[node];
}
}
void join(DisjointSet &ds, int u, int v){
int pu = find(ds, u);
int pv = find(ds, v);
if (pu == pv) return;
if(ds.r[pu] < ds.r[pv]) {
ds.p[pu] = pv;
ds.r[pv]++;
} else if (ds.r[pv] < ds.r[pu]) {
ds.p[pv] = pu;
ds.r[pu]++;
} else{
ds.p[pv] = pu;
}
}
int main() {
int n, m;
cin >> n >> m;
DisjointSet ds = init_ds(n);
while (m --){
int type, u, v;
cin >> type >> u >> v;
if (type == 1)
join(ds, u, v);
else{
int pu = find(ds, u);
int pv = find(ds, v);
(pu == pv) ? cout << "DA" : cout << "NU";
cout << "\n";
}
}
return 0;
}