#include <bits/stdc++.h>
using namespace std;
long long cnt;
struct EDGE {
  long long to;
  long long nxt;
  long long v;
} e[602020];
long long head[302020];
void build(long long from, long long to) {
  e[++cnt].to = to;
  e[cnt].nxt = head[from];
  head[from] = cnt;
}
bool vis[302020];
long long sz[302020];
long long ans[302020];
long long son[302020];
long long mx[302020];
long long fa[302020];
long long dep[302020];
long long root;
void dfs(long long p, long long de) {
  dep[p] = de;
  mx[p] = -1;
  vis[p] = 1;
  sz[p] = 1;
  for (long long i = head[p]; i; i = e[i].nxt) {
    long long k = e[i].to;
    if (!vis[k]) {
      dfs(k, de + 1);
      sz[p] += sz[k];
      if (sz[k] > mx[p]) {
        mx[p] = sz[k];
        son[p] = k;
      }
    }
  }
}
void PA(long long s, long long t) {
  if (mx[s] <= sz[t] / 2 && sz[t] - sz[s] <= sz[t] / 2) {
    ans[t] = s;
    return;
  } else
    return PA(fa[s], t);
}
void dfs2(long long p) {
  for (long long i = head[p]; i; i = e[i].nxt) {
    long long k = e[i].to;
    if (k != fa[p]) {
      dfs2(k);
    }
  }
  if (son[p] == 0)
    ans[p] = p;
  else
    PA(ans[son[p]], p);
}
signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  root = 1;
  long long n;
  long long m;
  cin >> n >> m;
  long long u, v;
  for (long long i = 2; i <= n; ++i) {
    cin >> u;
    fa[i] = u;
    build(u, i);
    build(i, u);
  }
  dfs(1, 1);
  dfs2(1);
  for (long long i = 1; i <= m; ++i) {
    long long k;
    cin >> k;
    cout << ans[k] << '\n';
  }
  return 0;
}
