#include <bits/stdc++.h>
using namespace std;
int hed[600010], nxt[600010], to[600010], cnt;
inline void addedge(int u, int v) {
  nxt[++cnt] = hed[u];
  hed[u] = cnt;
  to[cnt] = v;
}
int siz[300010], root[300010], ans[300010];
int mx[300010];
int id[6000010], son[6000010][2], tot;
int n, q;
int merge(int x, int y) {
  if (!x) return y;
  if (!y) return x;
  if (mx[id[y]] < mx[id[x]]) id[x] = id[y];
  son[x][0] = merge(son[x][0], son[y][0]);
  son[x][1] = merge(son[x][1], son[y][1]);
  return x;
}
void update(int &x, int l, int r, int p, int v, int i) {
  if (!x) x = ++tot;
  if (v < mx[id[x]]) id[x] = i;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (p <= mid)
    update(son[x][0], l, mid, p, v, i);
  else
    update(son[x][1], mid + 1, r, p, v, i);
}
int query(int a, int b, int k, int l, int r) {
  if (a > b || l > r || !k) return 0;
  if (a == l && b == r) return id[k];
  int mid = (l + r) >> 1;
  if (b <= mid)
    return query(a, b, son[k][0], l, mid);
  else if (a > mid)
    return query(a, b, son[k][1], mid + 1, r);
  else {
    int L = query(a, mid, son[k][0], l, mid),
        R = query(mid + 1, b, son[k][1], mid + 1, r);
    if (!L) return R;
    if (!R) return L;
    if (mx[L] < mx[R])
      return L;
    else
      return R;
  }
}
void dfs(int x) {
  siz[x] = 1;
  for (int i = hed[x]; i; i = nxt[i]) {
    int y = to[i];
    dfs(y);
    siz[x] += siz[y];
    root[x] = merge(root[x], root[y]);
    mx[x] = max(mx[x], siz[y]);
  }
  update(root[x], 1, n, siz[x], mx[x], x);
  ans[x] = query((siz[x] + 1) / 2, siz[x], root[x], 1, n);
}
int main() {
  scanf("%d%d", &n, &q);
  mx[0] = 1e9;
  for (int i = 2; i <= n; i++) {
    int p;
    scanf("%d", &p);
    addedge(p, i);
  }
  dfs(1);
  while (q--) {
    int x;
    scanf("%d", &x);
    printf("%d\n", ans[x]);
  }
  return 0;
}
