#include <iostream>
#include <fstream>
using namespace std;
int tata[100005], n, m;
ifstream fin ("disjoint.in");
ofstream fout ("disjoint.out");
///cautam radacina unui element x
int Find (int x){
int y, rad = x;
while (tata[rad] != 0){
rad = tata[rad];
}
///fiecare tata al lui x primeste legatura catre radacina
while (x != rad){
y = tata[x]; ///salvez in y pe tatal curent al lui x
tata[x] = rad; ///x primeste ca nou tata pe radacina
x = y; ///x acum se muta la fostul sau tata pentru a-l lega si pe el ulterior la radacina
}
return rad;
}
void Unificare (int x, int y){
tata[x] = y;
}
void Read()
{
fin >> n >> m;
int x, y, op;
for(int i = 1; i <= m; i++)
{
fin >> op >> x >> y;
x = Find (x);
y = Find (y);
if (op == 1)
Unificare(x, y);
else
{
if (x == y)
fout << "DA\n";
else
fout << "NU\n";
}
}
}
int main()
{
Read ();
return 0;
}