#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream cin ("disjoint.in" );
ofstream cout("disjoint.out");
vector <vector <int> > a;
int main()
{
int n, m, x, y, z;
cin >> n >> m;
a.resize(n + 1);
for (int i = 0; i < a.size(); i++)
a[i].push_back(i);
for (int i = 0; i < m; i++)
{
cin >> z >> x >> y;
if (z == 1)
{//unirea
if (x != y)
{
while (a[x].size() == 1 && a[x][0] != x)
x = a[x][0];
while (a[y].size() == 1 && a[y][0] != y)
y = a[y][0];
int q = a[x].size();
a[x].resize(q + a[y].size());
a[y].clear();
a[y].push_back(x);
}
}
else
{//afisarea
while (a[x].size() == 1 && a[x][0] != x)
x = a[x][0];
while (a[y].size() == 1 && a[y][0] != y)
y = a[y][0];
if (count(a[x].begin(), a[x].end(), y)) cout << "DA\n";
else cout << "NU\n";
}
}
return 0;
}