#include <iostream>
#include <fstream>
// problema: https://www.infoarena.ro/problema/disjoint
using namespace std;
const int IMAX = 1e5;
int p[IMAX+1], sz[IMAX+1];
int Find(int x) {
while (x != p[x]){ x = p[x]; }
return x;
}
void Union(int x, int y) {
x = Find(x);
y = Find(y);
if (sz[x] > sz[y]) {
p[y] = x;
sz[x] += sz[y];
}else {
p[x] = y;
sz[y] += sz[x];
}
}
int main() {
ifstream cin("disjoint.in");
ofstream cout("disjoint.out");
int n,q;
cin >> n >> q;
for (int i=1; i<=n; ++i) {
p[i] = i;
sz[i] = 1;
}
for (int i=1; i<=q; ++i) {
int op,x,y;
cin >> op >> x >> y;
if (op == 1) {
Union(x,y);
}else {
if (Find(x) != Find(y)) {
cout << "NU\n";
} else cout << "DA\n";
}
}
return 0;
}