#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 6;
struct Edge {
  int next, en;
} edge[maxn];
int head[maxn], cnt;
void init() {
  memset(head, -1, sizeof(head));
  cnt = 0;
}
void add(int x, int y) {
  edge[cnt].en = y;
  edge[cnt].next = head[x];
  head[x] = cnt++;
}
int ans[maxn], siz[maxn], fa[maxn], maxsiz[maxn];
void dfs(int x) {
  siz[x] = maxsiz[x] = 1;
  ans[x] = x;
  for (int i = head[x]; i + 1; i = edge[i].next) {
    int v = edge[i].en;
    fa[v] = x;
    dfs(v);
    siz[x] += siz[v];
    maxsiz[x] = max(maxsiz[x], siz[v]);
  }
  for (int i = head[x]; i + 1; i = edge[i].next) {
    int v = edge[i].en;
    int p = ans[v];
    while (p != x) {
      if (maxsiz[p] * 2 <= siz[x] && (siz[x] - siz[p]) * 2 <= siz[x]) {
        ans[x] = p;
        break;
      }
      p = fa[p];
    }
  }
}
int main() {
  int n, q, d;
  scanf("%d%d", &n, &q);
  init();
  for (int i = 2; i <= n; i++) {
    scanf("%d", &d);
    add(d, i);
  }
  dfs(1);
  while (q--) {
    scanf("%d", &d);
    printf("%d\n", ans[d]);
  }
  return 0;
}
