#include <fstream>
using namespace std;
ifstream fin("disjoint.in");
ofstream fout("disjoint.out");
int n, m, father[100005], rang[100005];
int find_root(int x) {
int root;
for (root = x; father[root] != root; root = father[root]);
for (int y; father[x] != x;) {
y = father[x];
father[x] = root;
x = y;
}
return root;
}
void unite(int x, int y) {
if (rang[x] > rang[y])
father[y] = x;
else
father[x] = y;
if (rang[x] == rang[y])
++rang[y];
}
int main()
{
fin >> n >> m;
for (int i = 1; i <= n; ++i) {
father[i] = i;
rang[i] = 1;
}
for (int i = 1; i <= m; ++i) {
int cod, x, y;
fin >> cod >> x >> y;
if (cod == 1)
unite(find_root(x), find_root(y));
else {
if (find_root(x) == find_root(y))
fout << "DA\n";
else
fout << "NU\n";
}
}
return 0;
}