/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
const int N_MAX = 100000;
ifstream fin("disjoint.in");
ofstream fout("disjoint.out");
int N, M;
int T[N_MAX + 5];
int find(int node) {
if(node == T[node]) {
return node;
}
return T[node] = find(T[node]);
}
void unite(int a, int b) {
a = find(a);
b = find(b);
T[a] = b;
}
int main()
{
fin >> N >> M;
for(int i = 1; i <= N; i++) {
T[i] = i;
}
while(M--) {
int t, a, b;
fin >> t >> a >> b;
if(t == 1) {
unite(a, b);
}
if(t == 2) {
if(find(a) == find(b)) {
fout << "DA\n";
}
else {
fout << "NU\n";
}
}
}
return 0;
}