func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxk = 20;   const int maxn = 3e5 + 17;   int N, Q;   int sub[maxn], ans[maxn];   vector<int> graph[maxn];   set<pair<int, int> > DFS(int u) {     sub[u] = 1;     set<pair<int, int> > cur;     for (int v : graph[u]) {       set<pair<int, int> > next = DFS(v);       if (next.size() >= cur.size()) swap(cur, next);       for (auto x : next) cur.insert(x);       sub[u] += sub[v];     }     cur.insert({sub[u], u});     ans[u] = cur.lower_bound({sub[u] + 1 >> 1, 0})->second;     return cur;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> N >> Q;     for (int i = 2; i <= N; i++) {       int x;       cin >> x;       graph[x].push_back(i);     }     DFS(1);     while (Q--) {       int x;       cin >> x;       cout << ans[x] << endl;     }     return 0;   }   