#include <bits/stdc++.h>
using namespace std;
int n, q;
const int N = 600001;
int nxt[N], first[N], go[N], tot, sz[N], f[N], ans[N], fa[N];
void add(int x, int y) {
  nxt[++tot] = first[x];
  first[x] = tot;
  go[tot] = y;
}
void dfs(int x) {
  ans[x] = x;
  sz[x] = 1;
  int maxn = 0, t = 0;
  for (int i = first[x]; i; i = nxt[i]) {
    int v = go[i];
    dfs(v);
    sz[x] += sz[v];
    if (sz[v] > maxn) {
      maxn = sz[v];
      t = v;
    }
  }
  f[x] = maxn;
  if (f[x] * 2 < sz[x])
    ans[x] = x;
  else {
    int now = ans[t];
    while (fa[now] &&
           max(f[now], sz[x] - sz[now]) > max(f[fa[now]], sz[x] - sz[fa[now]]))
      now = fa[now];
    ans[x] = now;
  }
}
int main() {
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int k;
    cin >> k;
    fa[i] = k;
    add(k, i);
  }
  dfs(1);
  for (int i = 1; i <= q; i++) {
    int k;
    cin >> k;
    cout << ans[k] << endl;
  }
}
