#include<bits/stdc++.h>
using namespace std;
int f[33333],infront[33333],num[33333],t,y,z,ans;
int fnt;
char c;
int find(int x){
if(fa[x]==x)return f[x];
else
fnt=find(f[x]);
infront[x]=infront[f[x]]+infront[x];
f[x]=fnt;
}
int main(){
int t;
cin>>t;
while(t--){
cin>>c>>y>>z;
int fx=find(y);
int fy=find(z);
if(c=='M'){
infront[fx]+=num[fy];
f[fx]=fy;
num[fy]+=num[fx];
num[fx]=0;
}
else
if(c=='C'){
if(fx!=fy){
cout<<-1<<endl;
}
else
cout<<abs(infront[fx]-infront[fy])-1<<endl;
}
}
return 0;
}
为什么RE了????