#include <iostream>
#include <fstream>
using namespace std;
#ifdef LOCAL
#define fin cin
#define fout cout
#else
ifstream fin("disjoint.in");
ofstream fout("disjoint.out");
#endif
int parinte[100001], cnt[100001];
int gaseste(int a) {
if (parinte[a] == a)
return a;
return parinte[a] = gaseste(parinte[a]);
}
void uneste(int a, int b) {
a = gaseste(a);
b = gaseste(b);
if (cnt[a] > cnt[b])
swap(a, b);
parinte[b] = a;
cnt[b] += cnt[a];
}
int main() {
int n, m, cod, a, b;
fin >> n >> m;
for (int i=1; i<=n; i++)
parinte[i] = i;
while (m--) {
fin >> cod >> a >> b;
if (cod == 1)
uneste(a, b);
else
fout << ((gaseste(a) == gaseste(b)) ? "DA" : "NU") << '\n';
}
}