#include <bits/stdc++.h>
using namespace std;
struct TREE {
  int nxt, to;
} t[305000];
int last[305000], cnt, jd[305000], ans[305000], fa[305000];
void build(int u, int v) {
  t[++cnt].to = v;
  t[cnt].nxt = last[u];
  last[u] = cnt;
}
int qfp(int x) {
  jd[x] = 1;
  ans[x] = x;
  int nmx = 0, nsum = 0;
  int e = last[x];
  while (e) {
    int v = t[e].to;
    jd[x] += qfp(v);
    if (jd[v] > jd[nmx]) nmx = v;
    e = t[e].nxt;
  }
  if (jd[nmx] * 2 > jd[x]) {
    int now = ans[nmx];
    while ((jd[x] - jd[now]) * 2 > jd[x]) {
      now = fa[now];
    }
    ans[x] = now;
  }
  return jd[x];
}
int max(int a, int b) { return a > b ? a : b; }
int main() {
  int i, j, k, m, n, a, q;
  scanf("%d%d", &n, &q);
  for (i = 2; i <= n; i++) {
    scanf("%d", &a);
    build(a, i);
    fa[i] = a;
  }
  jd[1] = 1 + qfp(1);
  for (i = 1; i <= q; i++) {
    scanf("%d", &a);
    cout << ans[a] << endl;
  }
  return 0;
}
