#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e5 + 5;
int n, q;
struct Edge {
  int to, nxt;
} e[MAX_N];
int head[MAX_N], tote;
void add_edge(int u, int v) {
  e[++tote].to = v, e[tote].nxt = head[u];
  head[u] = tote;
}
int siz[MAX_N], fa[MAX_N], ans[MAX_N];
void dfs(int u, int pre) {
  fa[u] = pre;
  siz[u] = 1;
  int son = -1;
  for (int i = head[u]; i; i = e[i].nxt) {
    int to = e[i].to;
    dfs(to, u);
    siz[u] += siz[to];
    if (son == -1 || siz[to] > siz[son]) son = to;
  }
  if (son == -1)
    ans[u] = u;
  else {
    son = ans[son];
    while ((2 * (siz[u] - siz[son])) > siz[u]) son = fa[son];
    ans[u] = son;
  }
}
void init() { memset(head, 0, sizeof(head)), tote = 0; };
int main() {
  init();
  scanf("%d", &n), scanf("%d", &q);
  for (register int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    add_edge(x, i);
  }
  dfs(1, 1);
  while (q--) {
    int x;
    scanf("%d", &x);
    printf("%d\n", ans[x]);
  }
  return 0;
}
