#include <fstream>
using namespace std;
int dsu[100005], tata = 0;
void find_tata(int nod)
{
if(nod != dsu[nod])
{
find_tata(dsu[nod]);
dsu[nod] = tata;
}
else
{
tata = nod;
}
}
int main()
{
ifstream cin("disjoint.in");
ofstream cout("disjoint.out");
int n, m;
cin>>n>>m;
for(int i = 1; i <= n; i++)
dsu[i] = i;
for(int i = 1; i <= m; i++)
{
int op, a, b;
cin>>op>>a>>b;
if(op == 1)
{
find_tata(a);
find_tata(b);
dsu[a] = tata;
}
else
{
int tata1, tata2;
find_tata(a);
tata1 = tata;
find_tata(b);
tata2 = tata;
if(tata1 == tata2)
cout<<"DA"<<'\n';
else
cout<<"NU"<<'\n';
}
}
return 0;
}