func_code_string: #include <bits/stdc++.h>   using namespace std;   int gi() {     int x = 0, w = 1;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) w = 0, ch = getchar();     while (ch >=  0  && ch <=  9 )       x = (x << 3) + (x << 1) + ch -  0 , ch = getchar();     return w ? x : -x;   }   const int N = 5e5 + 5;   struct node {     int h, nxt;   } a[N];   int n, m, nxt[N], head[N], val[N], ft[N];   char s[N];   int dep[N], sz[N], son[N], vis[N], sum[N], ans[N];   void add(int v, int h, int id) {     a[id] = (node){h, ft[v]};     ft[v] = id;   }   void dfs1(int u, int f) {     dep[u] = dep[f] + 1;     sz[u] = 1;     for (int v = head[u]; v; v = nxt[v]) {       dfs1(v, u), sz[u] += sz[v];       if (sz[v] > sz[son[u]]) son[u] = v;     }   }   void update(int u) {     sum[dep[u]] ^= val[u];     for (int v = head[u]; v; v = nxt[v])       if (!vis[v]) update(v);   }   bool cal(int x) {     int res = 0;     while (x) ++res, x ^= x & -x;     return res <= 1;   }   void dfs(int u, int f, int keep) {     for (int v = head[u]; v; v = nxt[v])       if (v != son[u]) dfs(v, u, 0);     if (son[u]) dfs(son[u], u, 1), vis[son[u]] = 1;     update(u);     for (int i = ft[u]; i; i = a[i].nxt) ans[i] = cal(sum[a[i].h]);     vis[son[u]] = 0;     if (!keep) update(u);   }   int main() {     n = gi();     m = gi();     for (int i = 2, f; i <= n; ++i) f = gi(), nxt[i] = head[f], head[f] = i;     scanf( %s , s + 1);     for (int i = 1; i <= n; ++i) val[i] = 1 << s[i] -  a ;     for (int i = 1, v, h; i <= m; ++i) v = gi(), h = gi(), add(v, h, i);     dfs1(1, 0);     dfs(1, 0, 1);     for (int i = 1; i <= m; ++i) puts(ans[i] ?  Yes  :  No );     return 0;   }   