#include<stdio.h>
#include<string.h>
#define N 100010
int father[N],link[N];
int find(int x) {
if(x!=father[x]) {
int h=father[x];
father[x]=find(father[x]);
link[x]=(link[x]+link[h])%2;
}
return father[x];
}
void insert(int x,int y) {
int xx=find(x);
int yy=find(y);
father[xx]=yy;
link[xx]=(link[x]+link[y]+1)%2;
}
int main() {
int t,n,m,a,b,i,f1,f2;
char s[3];
scanf("%d",&t);
while(t--) {
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++)
father[i]=i;
memset(link,0,sizeof(link));
while(m--) {
scanf("%s%d%d",s,&a,&b);
f1=find(a);
f2=find(b);
if(f1==f2) {
if(s[0]=='A') {
if(link[a]==link[b])
printf("In the same gang.
");
else
printf("In different gangs.
");
}
}
else {
if(s[0]=='A')
printf("Not sure yet.
");
else
insert(a,b);
}
}
}
return 0;
}