include[HTML_REMOVED]
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
const int MAX=1e5+10;
int p[MAX];
int find(int a)
{
if(a!=p[a]) p[a]=find(p[a]);
return p[a];
}
int main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;++i) p[i]=i;
char a[10];
int b,c;
while(m–)
{
scanf(“%s”,a);
scanf(“%d %d”,&b,&c);
if(a[0]==’M’)
{
if(find(c)==find(b)) continue;
else
{
p[find(c)]=find(b);
}
}
else
{
if(find(c)==find(b)) printf("Yes\n");
else printf("No\n");
}
}
system("pause");
return 0;
}