include

using namespace std;
//带权并查集难点就是关系更新,其他的与普通并查集无异
const int Maxn = 1e5;
int rel[Maxn+5],father[Maxn+5];
//0同1异
void init(int n)
{
for(int i = 1; i<=n; ++i)
{
father[i] = i;
rel[i] = 0;
}
}
int find(int x)
{
if(x!=father[x])
{
int px = find(father[x]);
rel[x] = rel[x]^rel[father[x]];
father[x] = px;
}
return father[x];
}
void _union(int a,int b)
{
int x = find(a);
int y = find(b);
if(x!=y)
{
father[x] = y;
rel[x] = !(rel[a]^rel[b]);
}
}
int main()
{
int t,n,m;
int a,b;
char c;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
init(n);
while(m--)
{
getchar();
scanf("%c%d%d",&c,&a,&b);
if(c=='D')
_union(a,b);
else if(find(a)==find(b))
if(rel[a]==rel[b])
puts("In the same gang.");
else
puts("In different gangs.");
else
puts("Not sure yet.");
}
}
return 0;
}