#include <bits/stdc++.h>
using namespace std;
const int nm=1e5+5;
int p[nm],h[nm];
int Find(int x){
while(x!=p[x]){
x=p[x];
}
return x;
}
void Union(int x, int y){
x=Find(x);
y=Find(y);
if(h[x]<h[y])swap(x,y);
p[y]=x;
h[x]+=h[y];
h[y]=0;
}
int main()
{
ifstream cin("disjoint.in");
ofstream cout("disjoint.out");
int n,m;
cin >> n >> m;
for(int i=1;i<=n;i++){
p[i]=i;
}
for(int i=1;i<=m;i++){
int c,a,b;
cin >> c >> a >> b;
if(c==1){
Union(a,b);
}
else{
if(Find(a)==Find(b))cout << "DA" <<'\n';
else cout << "NU" << '\n';
}
}
return 0;
}