#include <iostream>
#include <fstream>
#include <vector>
#include <bitset>
using namespace std;
ifstream in("disjoint.in");
ofstream out("disjoint.out");
int n, m;
int t[100001];
int rang[100001];
int Find(int k)
{
if (t[k] == 0)
return k;
else
{
int x = Find(t[k]);
t[k] = x;
return x;
}
}
void Union(int x, int y)
{
if (x != y)
{
if (rang[x] > rang[y])
t[y] = x;
else
{
t[x] = y;
if (rang[x] == rang[y])
rang[y]++;
}
}
}
int main()
{
in >> n >> m;
for (int i = 1; i <= m; i++)
{
int task, x, y;
in >> task >> x >> y;
if (task == 1)
Union(Find(x), Find(y));
else if (task == 2)
{
if (Find(x) == Find(y))
out << "DA\n";
else out << "NU\n";
}
}
return 0;
}