#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream fin("disjoint.in");
ofstream fout("disjoint.out");
vector<int> t;
int Find(int x) {
int rad = x, y;
while(t[rad] != 0)
rad = t[rad];
while(x != rad) {
y = t[x];
t[x] = rad;
x = y;
}
return rad;
}
void Union(int x, int y) {
t[x] = y;
}
int main()
{
int n, m; fin >> n >> m;
t.resize(n + 1);
for(int i = 0; i <= n; ++i)
t[i] = 0;
for(int i = 0; i < m; ++i)
{
int c, x, y; fin >> c >> x >> y;
if(c == 1)
{
int tata_x = Find(x), tata_y = Find(y);
if(tata_x != tata_y)
Union(tata_x, tata_y);
}
else
fout << (Find(x) == Find(y) ? "DA\n" : "NU\n");
}
return 0;
}