include [HTML_REMOVED]
using namespace std;
int n,m;
const int N=100010;
int p[N];
int find(int x){
if(x!=p[x]) p[x]=find(p[x]);
return p[x];
}
int main(){
scanf(“%d%d”,&n,&m);
for(int i=1;i<=N;i++) p[i]=i;
while(m–){
char op[2];
int x,y;
scanf(“%s%d%d”,op,&x,&y);
if(op[0]==’M’) p[find(x)]=find(y);
else{
if(find(x)==find(y)) puts(“Yes”);
else puts(“No”);
}
}
return 0;
}