#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("disjoint.in");
ofstream fout("disjoint.out");
int M, N;
int findset(vector<int> &tati, int nod) {
int u = nod;
while(tati[u] != 0) {
u = tati[u];
}
return u;
}
void dunionset(vector<int> &tati, vector<int> &inaltime, int u, int v) {
int a = findset(tati, u);
int b = findset(tati, v);
if(a != b) {
if(inaltime[a] > inaltime[b]) {
tati[b] = a;
} else if (inaltime[a] < inaltime[b]) {
tati[a] = b;
} else {
inaltime[b] += 1;
tati[a] = b;
}
}
}
int main() {
fin >> N >> M;
vector<int> tati(N+1, 0);
vector<int> inaltime(N+1, 0);
for (int i = 0; i < M; i++) {
int op, x, y;
fin >> op >> x >> y;
if(op == 1) {
dunionset(inaltime, tati, x, y);
} else if (op == 2) {
if(findset(tati, x) == findset(tati, y)) {
fout << "DA\n";
} else {
fout <<"NU\n";
}
}
}
}