#include <bits/stdc++.h>
using namespace std;
int n, m;
const int max_n = 300005;
struct edge {
  int to;
  int next;
} es[max_n * 2];
int head[max_n];
int cnt = 0;
int siz[max_n];
int heavyson[max_n];
int fa[max_n];
int ans[max_n];
void add(int u, int v) {
  es[cnt].to = v;
  es[cnt].next = head[u];
  head[u] = cnt++;
}
int dfs1(int u, int pre) {
  siz[u]++;
  int heavy = -1;
  for (int i = head[u]; i != -1; i = es[i].next) {
    int v = es[i].to;
    if (v != pre) {
      siz[u] += dfs1(v, u);
      if (heavy == -1 || siz[heavy] < siz[v]) heavy = v;
    }
  }
  heavyson[u] = heavy;
  return siz[u];
}
void dfs2(int u, int pre) {
  for (int i = head[u]; i != -1; i = es[i].next) {
    int v = es[i].to;
    if (v != pre) dfs2(v, u);
  }
  int bound = siz[u] / 2;
  if (heavyson[u] == -1 || siz[heavyson[u]] <= bound) {
    ans[u] = u;
    return;
  }
  for (int j = ans[heavyson[u]]; j != u; j = fa[j]) {
    if (siz[u] <= siz[j] * 2) {
      ans[u] = j;
      break;
    }
  }
}
int main() {
  int p, q;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) head[i] = -1;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &p);
    add(i, p);
    add(p, i);
    fa[i] = p;
  }
  memset(siz, 0, sizeof(siz));
  for (int i = 1; i <= n; i++) ans[i] = -1;
  dfs1(1, -1);
  dfs2(1, -1);
  for (int i = 0; i < m; i++) {
    scanf("%d", &p);
    printf("%d\n", ans[p]);
  }
  return 0;
}
