#include <cstdio>
#define nmax 100100
using namespace std;
int i, n, m, x, y, type;
int cnx[nmax];
int gr(int x)
{
if(x!=cnx[x]) cnx[x]=gr(cnx[x]);
return cnx[x];
}
void unite(int x, int y)
{
cnx[gr(x)]=gr(y);
}
int main()
{
freopen("disjoint.in", "rt", stdin);
freopen("disjoint.out", "wt", stdout);
scanf("%d%d", &n, &m);
for(i=1; i<=n; ++i) cnx[i]=i;
for(i=1; i<=m; ++i)
{
scanf("%d%d%d", &type, &x, &y);
if(type==1) unite(x, y);
else
{
if(gr(x)==gr(y)) printf("DA\n");
else printf("NU\n");
}
}
return 0;
}