#include <fstream>
using namespace std;
const int MAXN=100000;
ifstream in("disjoint.in");
ofstream out("disjoint.out");
int n,m,sef[MAXN+1];
int sef_suprem(int nod)
{
if(sef[nod]==nod) return nod;
sef[nod]=sef_suprem(sef[nod]);
return sef[nod];
}
void onion (int x, int y)
{
int sefx=sef_suprem(x);
int sefy=sef_suprem(y);
sef[sefx]=sefy;
}
int main()
{
in>>n>>m;
int cod,x,y;
for(int i=1;i<=n;i++) sef[i]=i;
for(int i=1;i<=m;i++)
{
in>>cod>>x>>y;
if(cod==1) onion(x,y);
else
{
if(sef_suprem(x)==sef_suprem(y)) out<<"DA\n";
else out<<"NU\n";
}
}
return 0;
}