#include <bits/stdc++.h>
using namespace std;
const int Maxn = 300000 + 5;
const int Root = 1;
int Ans[Maxn];
int qry[Maxn];
struct Edge {
  int v, nxt;
  Edge() {}
  Edge(int v0, int n0) {
    v = v0;
    nxt = n0;
  }
};
Edge e[Maxn];
int head[Maxn];
int nume;
int fa[Maxn], dep[Maxn], siz[Maxn], son[Maxn];
int n, m;
void treeDP(int x) {
  dep[x] = dep[fa[x]] + 1;
  siz[x] = 1;
  for (int i = head[x]; i; i = e[i].nxt) {
    treeDP(e[i].v);
    siz[x] += siz[e[i].v];
    if (siz[e[i].v] > siz[son[x]]) son[x] = e[i].v;
  }
  if (siz[son[x]] <= siz[x] / 2) {
    Ans[x] = x;
    return;
  }
  for (int i = head[x]; i; i = e[i].nxt) {
    int v = Ans[e[i].v];
    int len = 0;
    while (v != x) {
      len = max(siz[x] - siz[v], siz[son[v]]);
      if (len <= siz[x] / 2) {
        Ans[x] = v;
        return;
      }
      v = fa[v];
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= n; i++) {
    int tmp;
    scanf("%d", &tmp);
    e[++nume] = Edge(i, head[tmp]);
    head[tmp] = nume;
    fa[i] = tmp;
  }
  for (int i = 1; i <= m; i++) scanf("%d", &qry[i]);
  treeDP(Root);
  for (int i = 1; i <= m; i++) {
    printf("%d\n", Ans[qry[i]]);
  }
  return 0;
}
