#include<bits/stdc++.h>
#define For(aa,bb,cc) for(int aa=(bb);aa<=(int)(cc);++aa)
#define Forr(aa,bb,cc) for(int aa=(bb);aa>=(int)(cc);--aa)
using namespace std;
typedef long long LL;
const int maxn=3e5+10,K=19;
int n,m;
int be[maxn],ne[maxn<<1],to[maxn<<1],e;
int pos[maxn];
int f[maxn][20];
int dfn[maxn],dfr[maxn],dep[maxn];
inline void add_edge(int x,int y){
to[++e]=y,ne[e]=be[x],be[x]=e;
to[++e]=x,ne[e]=be[y],be[y]=e;
}
template<class T>inline void read(T &x){
x=0;char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
}
namespace Bit{
const int N=3e5;
int sum[maxn];
inline int lowbit(int x){ return x&(-x); }
void update(int x,int y){
for(;x<=N;x+=lowbit(x)) sum[x]+=y;
}
int query(int x){
int res=0;
for(;x;x-=lowbit(x)) res+=sum[x];
return res;
}
}using namespace Bit;
void dfs(int node){
static int tot=0;
dfn[node]=++tot;
For(i,1,K){
if(!f[f[node][i-1]][i-1]) break;
f[node][i]=f[f[node][i-1]][i-1];
}
for(int i=be[node];i;i=ne[i]){
int u=to[i];
if(u==f[node][0]) continue;
dep[u]=dep[node]+1;
f[u][0]=node;
dfs(u);
}
dfr[node]=tot;
}
int ask(int x,int y){
if(dep[x]<dep[y]) swap(x,y);
int d=dep[x]-dep[y];
Forr(i,K,0) if(d&(1<<i)) x=f[x][i];
if(x==y) return x;
Forr(i,K,0) if(f[x][i]!=f[y][i]) x=f[x][i],y=f[y][i];
return f[x][0];
}
int main(){
int x,y,cnt=0;
read(n),read(m);
For(i,1,n-1) read(x),read(y),add_edge(x,y);
dfs(1);
char s[2];
while(m--){
scanf("%s",s);
if(s[0]=='Q'){
read(x),read(y);
int res=query(dfn[x])+query(dfn[y])-2*query(dfn[ask(x,y)]);
if(!res) puts("Yes");
else puts("No");
}
else if(s[0]=='C'){
read(x),read(y);
if(dep[x]<dep[y]) swap(x,y);
//printf("%d %d %d %d\n",x,y,dfn[x],dfr[x]);
update(dfn[x],1),update(dfr[x]+1,-1);
pos[++cnt]=x;
}
else{
read(x);
update(dfn[pos[x]],-1),update(dfr[pos[x]]+1,1);
}
}
return 0;
}