#include <bits/stdc++.h>
using namespace std;
ifstream fin("disjoint.in");
ofstream fout("disjoint.out");
const int nmax = 100005;
int findRep(int* parent, int x){
if(x == parent[x])
return x;
else return findRep(parent, parent[x]);
}
void reunion(int* parent, int x, int y){
int repX = findRep(parent, x);
int repY = findRep(parent, y);
parent[repX] = repY;
}
int main(){
int* parent = new int[nmax];
int N, M;
fin >> N >> M;
for(int i = 1; i <= N; ++i)
parent[i] = i;
for(int i = 1; i <= M; ++i){
int cod, x, y;
fin >> cod >> x >> y;
if(cod == 2)
if(findRep(parent, x) == findRep(parent, y))
fout << "DA\n";
else
fout << "NU\n";
else
reunion(parent, x, y);
}
return 0;
}