#include <bits/stdc++.h>
using namespace std;
ifstream fin("disjoint.in");
ofstream fout("disjoint.out");
const int LMAX = 1e5 + 7;
int t[LMAX];
int n, m;
void join(int x, int y);
int get_root(int x);
bool query(int x, int y);
int main()
{
fin >> n >> m;
for (int i = 1; i <= m; i++)
{
int type, x, y;
fin >> type >> x >> y;
if (type == 1)
{
join(x, y);
}
else
{
fout << (query(x, y) ? "DA\n" : "NU\n");
}
}
return 0;
}
bool query(int x, int y)
{
return get_root(x) == get_root(y);
}
void join(int x, int y)
{
int root_x = get_root(x);
int root_y = get_root(y);
if (root_x == root_y)//sunt in acelasi arbore
{
return;
}
if (t[root_x] <= t[root_y])
{
t[root_y] = root_x;
}
else
{
t[root_x] = root_y;
}
}
int get_root(int x)
{
int aux = x;
while (t[x] > 0)
{
x = t[x];
}
int root = x;
x = aux;
while (x != root)
{
aux = t[x];
t[x] = root;
x = aux;
}
return root;
}