#include <stdio.h>
#include <iostream>
using namespace std;
const int maxn = 3e5+4;
int c[maxn+5],n,m;
int size[maxn],top[maxn],son[maxn],tin[maxn],tout[maxn],cloc,fat[maxn],dep[maxn],que[maxn],q;
inline int lowbit(int x){return x&(-x);}
inline int sum(int x){int ret = 0;while(x){ret+=c[x];x-=lowbit(x);}return ret;}
inline void inc(int x,int a){while(x<=(cloc)+5){c[x]+=a;x+=lowbit(x);}}
int head[maxn],nex[maxn*2],dist[maxn*2],qq;
inline void connect(int a,int b){nex[++qq] = head[a];dist[qq] = b;head[a] = qq;nex[++qq] = head[b];dist[qq] = a;head[b] = qq;}
void dfs(int a,int fa){
dep[a] = dep[fa]+1;
fat[a] = fa;
tin[a] = ++cloc;
son[a] = -1;
for(int i = head[a];i;i=nex[i]){
int to = dist[i];
if(to!=fa){
dfs(to,a);
size[a]+=size[to];
if(son[a]==-1||size[to]>size[son[a]]){
son[a] = to;
}
}
}
tout[a]= cloc+1;
}
void dfs2(int a,int t){
top[a] = t;
if(son[a]==-1) return;
dfs2(son[a],t);
for(int i = head[a];i;i=nex[i]){
int to = dist[i];
if(to!=fat[a]&&to!=son[a]){
dfs2(to,to);
}
}
}
int lca(int x,int y){
while(top[x]!=top[y]){
if(dep[top[x]]>dep[top[y]])
x = fat[top[x]];
else
y = fat[top[y]];
}
return dep[x]<dep[y]?x:y;
}
int read()
{
int x=0;
char ch=getchar();
while(ch<'0'||ch>'9') ch=getchar();
while(ch>='0'&&ch<='9')
{
x=x*10+ch-'0';
ch=getchar();
}
return x;
}
int main(){
n = read(),m = read();
int s = 1;
for(int i = 1;i<=n-1;i++){
int x,y;x=read(),y=read();
connect(x,y);
}
dfs(n/2,n/2);
dfs2(n/2,n/2);
for(int i = 1;i<=m;i++){
char c;cin>>c;
if(c=='Q'){
int x=read(),y=read();
if(!(sum(tin[x])+sum(tin[y])-2*sum(tin[lca(x,y)]))){
puts("Yes");
}else{
puts("No");
}
}else if(c=='C'){
int x=read(),y=read();
if(dep[x]<dep[y]) x = y;
inc(tin[x],1);inc(tout[x],-1);
que[++q] = x;
}else{
int x=read();
inc(tin[que[x]],-1);
inc(tout[que[x]],1);
}
}
return 0;
}