#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int sub[N], in[N], out[N], ans[N], p[N], big[N];
vector<int> adj[N];
int n, q, t;
void pre(int u, int par) {
  sub[u] = 1;
  in[u] = t++;
  big[u] = -1;
  for (int nxt : adj[u]) {
    if (nxt == par) continue;
    pre(nxt, u);
    sub[u] += sub[nxt];
    if (big[u] == -1 || sub[nxt] > sub[big[u]]) big[u] = nxt;
  }
  out[u] = t - 1;
}
bool is_anc(int u, int v) { return in[u] <= in[v] && out[v] <= out[u]; }
int get_answer(int u, int par, int root) {
  int mx = max(sub[big[u]], sub[root] - sub[u]);
  if (2 * mx <= sub[root]) return u;
  return get_answer(big[u], u, root);
}
void solve(int u, int par) {
  if (is_anc(u, ans[par])) {
    ans[u] = get_answer(ans[par], p[ans[par]], u);
  } else {
    ans[u] = get_answer(u, p[u], u);
  }
  for (int nxt : adj[u]) {
    if (nxt == par) continue;
    solve(nxt, u);
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  in[0] = INT_MIN;
  out[0] = INT_MAX;
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    cin >> p[i];
    adj[p[i]].push_back(i);
  }
  pre(1, 0);
  solve(1, 0);
  while (q--) {
    int u;
    cin >> u;
    cout << ans[u] << "\n";
  }
  return 0;
}
