#include <stdio.h>
int N, Q;
int x[400001][3];
int pa[200001], gr[200001], ans[200001];
int dfs(int n){
if(n != gr[n]) gr[n] = dfs(gr[n]);
return gr[n];
}
int main()
{
scanf("%d %d", &N, &Q);
for(int i = 2; i <= N; i++){
scanf("%d", &pa[i]);
}
gr[1] = 1;
for(int i = 0; i < N + Q - 1; i++){
scanf("%d", &x[i][0]);
if(x[i][0] == 1)
scanf("%d %d", &x[i][1], &x[i][2]);
else
scanf("%d", &x[i][1]);
}
for(int i = 1; i < N; i++){
gr[i] = i;
}
int tmp = Q;
for(int i = N + Q - 2; i >= 0; i--){
if(x[i][0] == 0){
gr[x[i][1]] = pa[x[i][1]];
}
else if(x[i][0] == 1){
if(dfs(gr[x[i][1]]) == dfs(gr[x[i][2]])) ans[tmp] = 1;
else ans[tmp] = 0;
tmp--;
}
}
for(tmp = 1; tmp <= Q; tmp++){
if(ans[tmp]) printf("YES\n");
else printf("NO\n");
}
return 0;
}
ÀÌ Äڵ尡 ¼±»ý´ÔÀÌ Ç®ÀÌÇÑ ÄÚµå¿Í À̸§¸¸ ¹Ù²ï ÄÚµåÀÔ´Ï´Ù.
¿Ö ÀÌ Äڵ尡 98Á¡¹Û¿¡ ¾È ³ª¿Ã±î¿ä?