#include <iostream>
#include <fstream>
#include <cstdio>
using namespace std;
int t[100001], r[100000];
int cauta(int x)
{
int p,y;
for (p=x;p!=t[p];p=t[p]);
for (;t[x]!=x;)
{
y=t[x];
t[x]=p;
x=y;
}
return p;
}
int combina(int x,int y)
{
if (r[x]>r[y]) t[y]=x;
else t[x]=y;
if (r[x]==r[y]) r[y]++;
}
int main()
{
int m,n,i,x,y,z;
freopen("disjoint.in","r",stdin);
freopen("disjoint.out","w",stdout);
scanf("%d %d",&n,&m);
for (i=0;i<=n;i++)
{
r[i]=1;
t[i]=i;
}
for (i=1;i<=m;i++)
{
scanf("%d %d %d",&x,&y,&z);
if (x==1) {if (cauta(y)!=cauta(z)) combina(cauta(y),cauta(z));}
else if (cauta(y)==cauta(z)) cout<<"DA\n";
else cout<<"NU\n";
}
}