#include <bits/stdc++.h>
using namespace std;
const int N = 2000010;
struct edge {
  int to, nxt;
} e[N];
int ans[N], mx[N], head[N], fa[N], n, m, size[N], cnt;
void add(int x, int y) {
  e[++cnt].to = y;
  e[cnt].nxt = head[x];
  head[x] = cnt;
}
void dfs(int x, int father) {
  ans[x] = x;
  mx[x] = 0;
  size[x] = 1;
  fa[x] = father;
  int id = 0;
  for (int i = head[x]; i != -1; i = e[i].nxt) {
    int v = e[i].to;
    if (v == father) continue;
    dfs(v, x);
    if (size[v] > mx[x]) {
      mx[x] = size[v];
      id = v;
    }
    size[x] += size[v];
  }
  if (mx[x] * 2 < size[x])
    ans[x] = x;
  else {
    int num = ans[id];
    while (fa[num] && max(mx[num], size[x] - size[num]) >
                          max(mx[fa[num]], size[x] - size[fa[num]]))
      num = fa[num];
    ans[x] = num;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  memset(head, -1, sizeof(head));
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    add(i, x);
    add(x, i);
  }
  dfs(1, 0);
  while (m--) {
    int x;
    scanf("%d", &x);
    printf("%d\n", ans[x]);
  }
  return 0;
}
