#include <bits/stdc++.h>
using namespace std;
int n, m, f[300005], head[300005], rt[300005], size[300005], mx[300005], cnt;
struct edge {
  int to, nxt;
} e[300005];
void dfs(int x) {
  size[x] = 1;
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].to;
    dfs(y);
    size[x] += size[y];
    mx[x] = max(mx[x], size[y]);
  }
  int id = x, me = mx[x];
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].to;
    int it = rt[y], pre = max(mx[it], size[x] - size[it]), p = it;
    while (f[it] != x) {
      it = f[it];
      int New = max(mx[it], size[x] - size[it]);
      if (New < pre)
        pre = New, p = it;
      else
        break;
    }
    if (me > pre) me = pre, id = p;
  }
  rt[x] = id;
}
int main() {
  cin >> n >> m;
  for (int i = 2; i <= n; ++i) {
    scanf("%d", &f[i]);
    e[++cnt] = {i, head[f[i]]};
    head[f[i]] = cnt;
  }
  dfs(1);
  while (m--) {
    int x;
    scanf("%d", &x);
    printf("%d\n", rt[x]);
  }
  return 0;
}
