#include <fstream>
using namespace std;
ifstream cin("disjoint.in");
ofstream cout("disjoint.out");
int sef[100001];
int sef_suprem(int x){
if(sef[x] == x){
return x;
}
return sef[x] = sef_suprem(sef[x]);
}
void join(int x, int y){
int sefx = sef_suprem(x);
int sefy = sef_suprem(y);
sef[sefx] = sefy;
}
int main()
{
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i++){
sef[i] = i;
}
for(int i = 1; i <= m; i++){
int c, x, y;
cin >> c >> x >> y;
if(c == 1){
join(x, y);
}
else{
if(sef_suprem(x) == sef_suprem(y)){
cout << "DA\n";
}
else{
cout << "NU\n";
}
}
}
return 0;
}