func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<long long> adj[500005];   vector<pair<long long, long long>> vc[500005];   string s;   bool ans[500005], hv[500005];   long long level[500005], sz[500005], heavy[500005], cnt[500005], col[500005];   void dfs(long long u, long long p, long long l = 1) {     sz[u] = 1, heavy[u] = -1, level[u] = l;     for (long long i = 0; i < adj[u].size(); i++) {       long long v = adj[u][i];       if (v == p) continue;       dfs(v, u, l + 1);       sz[u] += sz[v];       if (heavy[u] == -1 || sz[v] > sz[heavy[u]]) heavy[u] = v;     }   }   void Add(long long u, long long p) {     cnt[level[u]] ^= (1 << col[u]);     for (long long i = 0; i < adj[u].size(); i++) {       long long v = adj[u][i];       if (v == p || hv[v]) continue;       Add(v, u);     }   }   void dsu(long long u, long long p, bool flg) {     for (long long i = 0; i < adj[u].size(); i++) {       long long v = adj[u][i];       if (v == p || v == heavy[u]) continue;       dsu(v, u, 0);     }     if (~heavy[u]) dsu(heavy[u], u, 1), hv[heavy[u]] = 1;     Add(u, p);     for (auto v : vc[u]) {       long long ht = v.first;       long long id = v.second;       if (__builtin_popcountll(cnt[ht]) <= 1) ans[id] = 1;     }     if (~heavy[u]) hv[heavy[u]] = 0;     if (flg == 0) Add(u, p);   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long i, j, k, p, q, m, n;     cin >> n >> m;     for (i = 2; i <= n; i++) {       cin >> p;       adj[p].push_back(i);       adj[i].push_back(p);     }     cin >> s;     for (i = 0; i < s.size(); i++) {       col[i + 1] = s[i] -  a ;     }     for (i = 1; i <= m; i++) {       cin >> p >> q;       vc[p].push_back({q, i});     }     dfs(1, -1);     dsu(1, -1, 0);     for (i = 1; i <= m; i++) {       if (ans[i])         cout <<  Yes               <<   n ;       else         cout <<  No               <<   n ;     }     return 0;   }   