#include <bits/stdc++.h>
#include <utility>
using namespace std;
#ifdef INFOARENA
ifstream fin("disjoint.in");
ofstream fout("disjoint.out");
#define cin fin
#define cout fout
#endif
struct DSU {
vector<int> size;
vector<int> comp;
DSU(int n) : size(n + 1), comp(n + 1) {
fill(size.begin(), size.end(), 1);
iota(comp.begin(), comp.end(), 0);
}
int find(int node) {
if (comp[node] == node)
return node;
return comp[node] = find(comp[node]);
}
bool merge(int x, int y) {
int comp_x = find(x);
int comp_y = find(y);
if (comp_x == comp_y)
return false;
if (size[comp_x] > size[comp_y])
swap(comp_x, comp_y);
size[comp_y] += size[comp_x];
comp[comp_x] = comp_y;
return true;
}
};
int main() {
int n, m;
cin >> n >> m;
DSU dsu(n);
while (m--) {
int op, x, y;
cin >> op >> x >> y;
if (op == 1) {
dsu.merge(x, y);
} else {
cout << (dsu.find(x) == dsu.find(y) ? "DA" : "NU") << '\n';
}
}
}