#include <fstream>
std::ifstream cin("disjoint.in");
std::ofstream cout("disjoint.out");
int root[100001];
int n, m;
int find_root(const int node) {
if(node == root[node]) return node;
root[node] = find_root(root[node]);
return root[node];
}
void unite(const int x, const int y) {
int r_x = find_root(x);
int r_y = find_root(y);
root[r_x] = r_y;
}
int main() {
cin >> n >> m;
for(int i = 1; i <= n; ++i) root[i] = i;
while(m--) {
int op, x, y;
cin >> op >> x >> y;
if(op == 1) {
unite(x, y);
}
else if(op == 2) {
if(find_root(x) == find_root(y)) cout << "DA\n";
else cout << "NU\n";
}
}
}