#include<bits/stdc++.h>
inline const void read(int &a)
{
a=0;char c=getchar();
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9')
{
a=(a<<1)+(a<<3)+c-'0';
c=getchar();
}
}
inline const void write(int a)
{
if(a<0){putchar('-');a=-a;}
if(a>=10)write(a/10);
putchar(a%10+'0');
}
#define maxn 100001
int n,m,d=0;
int next[maxn],to[maxn],point[maxn],deep[maxn],father[maxn],son[maxn];
int num[maxn];
inline const void add(int a,int b)
{
next[++d]=point[a];
point[a]=d;
to[d]=b;
}
#define lowbit(a) a&(-a)
int sum[maxn];
inline const void modify(int a,int b)
{
while(a<=n)
{
sum[a]+=b;
a+=lowbit(a);
}
}
inline const int query(int a)
{
int ans=0;
while(a)
{
ans+=sum[a];
a-=lowbit(a);
}
return ans;
}
inline const int dfs1(int p)
{
int side=point[p];
num[p]=1;
while(side)
{
if(to[side]!=father[p])
{
father[to[side]]=p;
deep[to[side]]=deep[p]+1;
num[p]+=dfs1(to[side]);
if(num[to[side]]>num[son[p]])son[p]=to[side];
}
side=next[side];
}
return num[p];
}
int loc[maxn],top[maxn];
int cnt=0,left[maxn],right[maxn];
inline const void dfs2(int p,int tp)
{
loc[p]=++cnt;
left[p]=cnt;
top[p]=tp;
int side=point[p];
if(son[p])dfs2(son[p],tp);
while(side)
{
if(to[side]!=father[p]&&to[side]!=son[p])
{
dfs2(to[side],to[side]);
}
side=next[side];
}
right[p]=cnt;
modify(loc[p],1);modify(right[p]+1,-1);
}
int main()
{
memset(father,0,sizeof(father));
memset(deep,0,sizeof(deep));
memset(point,0,sizeof(point));
memset(sum,0,sizeof(sum));
memset(num,0,sizeof(num));
memset(son,0,sizeof(son));
read(n);read(m);
int u,v,x;
for(int i=1;i<=n-1;i++)
{
read(u);read(v);
add(u,v);add(v,u);
}
dfs1(1);
dfs2(1,1);
char c;
int change1[maxn],change2[maxn],r=0;
while(m)
{
scanf("%c",&c);
if(c=='Q')
{
bool yes=true;
read(u);read(v);
while(top[u]!=top[v])
{
if(deep[top[u]]<deep[top[v]])std::swap(u,v);
if(query(loc[u])-query(loc[top[u]]-1)<deep[u]-deep[top[u]]){yes=false;break;}
u=father[top[u]];
}
if(deep[u]<deep[v])std::swap(u,v);
if(query(loc[u])-query(loc[v]-1)<deep[u]-deep[top[u]])yes=false;
if(!yes)puts("No");
else puts("Yes");
}
if(c=='C')
{
read(u);read(v);
if(deep[u]>deep[v])std::swap(u,v);
change1[++r]=u;change2[r]=v;
modify(loc[u],-1);modify(right[u]+1,1);
}
if(c=='U')
{
read(x);
u=change1[x];v=change2[x];
modify(loc[u],1);modify(right[u]+1,-1);
}
m--;
}
return 0;
}