#include <bits/stdc++.h>
using namespace std;
int n, q;
vector<int> adj[3 * 100010];
int ans[3 * 100010];
int szp[3 * 100010];
int big[3 * 100010];
int p[3 * 100010];
void sz(int i) {
  szp[i] = 1;
  for (auto j : adj[i]) {
    sz(j);
    big[i] = max(big[i], szp[j]);
    szp[i] += szp[j];
  }
}
bool check(int v, int u) {
  return (((szp[v] - szp[u]) * 2 <= szp[v]) and (big[u] * 2 <= szp[v]));
}
void dfs(int i) {
  if (adj[i].size() == 0) {
    ans[i] = i;
    return;
  }
  int res = 0, mx = 0;
  for (auto j : adj[i]) {
    dfs(j);
    if (szp[j] > mx) {
      mx = szp[j];
      res = j;
    }
  }
  int u = ans[res];
  while (!check(i, u)) {
    u = p[u];
  }
  ans[i] = u;
}
int main() {
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    cin >> p[i];
    adj[p[i]].push_back(i);
  }
  sz(1);
  dfs(1);
  while (q--) {
    int x;
    cin >> x;
    cout << ans[x] << endl;
  }
}
