#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
int n, q;
int p[300005];
int sz[300005];
vector<int> g[300005];
int ct[300005], mx[300005];
void dfs(int u) {
  sz[u] = 1;
  for (auto v : g[u]) {
    dfs(v);
    sz[u] += sz[v];
    mx[u] = max(mx[u], sz[v]);
  }
}
set<pair<int, int> > slv(int u) {
  set<pair<int, int> > ss;
  ss.insert({sz[u], u});
  for (auto v : g[u]) {
    set<pair<int, int> > ps = slv(v);
    if (ps.size() > ss.size()) {
      swap(ps, ss);
    }
    for (auto x : ps) {
      ss.insert(x);
    }
  }
  ct[u] = ss.lower_bound({(sz[u] + 1) / 2, 0})->second;
  return ss;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    cin >> p[i];
    g[p[i]].push_back(i);
  }
  dfs(1);
  slv(1);
  int x;
  while (q--) {
    cin >> x;
    cout << ct[x] << '\n';
  }
  return 0;
}
