#include<stdio.h> #include<iostream> using namespace std; long set[505000]; long rank[505000]; long findset(long x){ long y=x; if(set[x]==x) return x; y=findset(set[x]); rank[x]=(rank[set[x]]+rank[x])%2; set[x]=y; return y; } void unions(long x,long y){ long a,b; a=findset(x); b=findset(y); set[b]=a; rank[b]=(rank[x]+rank[y]+1)%2; } int main(){ long t,n,m,x,y,a,b; char c; scanf("%d",&t); for(long i=0;i<t;i++){ //scanf("%d %d\n",&n,&m); scanf("%d %d",&n,&m); for(long j=1;j<=n;j++){ set[j]=j; rank[j]=0; } for(long j=0;j<m;j++){ //scanf("%c %d %d\n",&c,&x,&y); getchar(); scanf("%c %d %d",&c,&x,&y); a=findset(x); b=findset(y); //cout<<a<<" "<<b<<" "<<rank[x]<<" "<<rank[y]<<endl; if(c=='D') unions(x,y); else if(c=='A'){ if(a!=b) {cout<<"Not sure yet."<<endl; continue;} if(a==b){ if(rank[x]==rank[y]) {cout<<"In the same gang."<<endl; continue;} else {cout<<"In different gangs."<<endl; continue;} } } } } return 0; }