#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
using namespace std;
#define maxn 100010
int fa[maxn], turn[maxn];
int find( int x)
{
if(fa[x] == x)
return x;
int tem = find(fa[x]);
turn[x] = (turn[x] + turn[fa[x]])%2;
return fa[x] = tem;
}
void unio( int x, int y)
{
int fx, fy;
fx = find(x);
fy = find(y);
if(fx != fy)
{
fa[fx] = fy;
turn[fx] = (2 - turn[x] + turn[y] + 1)%2;
}
return ;
}
int main()
{
int t,n,m;
char s;
int a, b;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&n, &m);
for( int i = 0; i < n; i++)
{
turn[i] = 0;
fa[i] = i;
}
for( int i = 0; i < m; i++)
{
getchar();
scanf("%c%d%d",&s, &a, &b);
if(s == 'D')
{
unio(a, b);
}
else
{
int fx = find(a);
int fy = find(b);
if(fx != fy)
{
printf("Not sure yet.\n");
}
else
{
if((turn[a] +turn[b])%2==0)
printf("In the same gang.\n");
else
printf("In different gangs.\n");
}
}
}
}
return 0;
}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
using namespace std;
#define maxn 100010
int fa[maxn], turn[maxn];
int find( int x)
{
if(fa[x] == x)
return x;
int tem = find(fa[x]);
turn[x] = (turn[x] + turn[fa[x]])%2;
return fa[x] = tem;
}
void unio( int x, int y)
{
int fx, fy;
fx = find(x);
fy = find(y);
if(fx != fy)
{
fa[fx] = fy;
turn[fx] = (2 - turn[x] + turn[y] + 1)%2;
}
return ;
}
int main()
{
int t,n,m;
char s;
int a, b;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&n, &m);
for( int i = 0; i < n; i++)
{
turn[i] = 0;
fa[i] = i;
}
for( int i = 0; i < m; i++)
{
getchar();
scanf("%c%d%d",&s, &a, &b);
if(s == 'D')
{
unio(a, b);
}
else
{
int fx = find(a);
int fy = find(b);
if(fx != fy)
{
printf("Not sure yet.\n");
}
else
{
if((turn[a] +turn[b])%2==0)
printf("In the same gang.\n");
else
printf("In different gangs.\n");
}
}
}
}
return 0;
}