#include <iostream>
#include <vector>
#include <bitset>
#include <fstream>
using namespace std;
ifstream fin ("disjoint.in");
ofstream fout ("disjoint.out");
int t[100001], r[100001];
int Find (int x)
{
if (t[x] == 0)
return x;
int y = Find(t[x]);
t[x] = y;
return y;
}
void Union(int x, int y)
{
if (r[x] > r[y])
{
t[y] = x;
r[x] += r[y];
}
else {
t[x] = y;
r[y] += r[x];
}
}
int main()
{
int n, op;
fin >> n >> op;
for (int i = 1; i <= n; i++)
r[i] = 1;
while (op--)
{
int tip, x, y;
fin >> tip >> x >> y;
x = Find(x);
y = Find(y);
if (tip == 1 && x != y)
Union(x, y);
else if (tip == 2)
fout << ((x == y) ? "DA\n" : "NU\n");
}
return 0;
}