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