#include <bits/stdc++.h>
using namespace std;
ifstream fin("disjoint.in");
ofstream fout("disjoint.out");
int tata[100005], rang[100005];
int cautare_tata(int nod)
{///cautam nodul sursa ,nu tatal direct
while( tata[nod] != nod)
nod = tata[nod];
return nod;
}
void unire_arbori(int x, int y)
{ ///intodeauna unim arborele mai mic cu cel mare
if(rang[x] < rang[y])
tata[x] = y;
else
if(rang[y] < rang[x])
tata[y] = x;
else
if(rang[x] == rang[y])
{
tata[x]=y;
rang[y]++;
}
}
int main()
{
int n,m,x,y,op;
fin >> n >> m;
for(int i = 1; i <= m; i++)
{
tata[i]=i;
rang[i]=1;
}
for(int i = 1; i <= m; i++)
{
fin>>op>>x>>y;
if(op==1)
unire_arbori(x,y);
else
if(cautare_tata(x)==cautare_tata(y)) ///daca au acs tata inseamna ca fac parte din acs multime
fout<<"DA\n";
else
fout<<"NU\n";
}
return 0;
}