#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-10;
const long long mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxn = 300005;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, q, tot;
struct edge {
  int to, nxt;
} es[maxn * 2];
int head[maxn], sz[maxn], f[maxn], g[maxn], father[maxn];
void init() {
  tot = 0;
  memset(head, -1, sizeof(head));
}
void addEdge(int u, int v) {
  es[tot].to = v;
  es[tot].nxt = head[u];
  head[u] = tot++;
}
bool ck(int u, int c) {
  return (sz[u] - sz[c]) * 2 <= sz[u] && sz[f[c]] * 2 <= sz[u];
}
void dfs(int u, int fa) {
  sz[u] = 1;
  f[u] = 0;
  father[u] = fa;
  for (int i = head[u]; i != -1; i = es[i].nxt) {
    int v = es[i].to;
    if (v == fa) continue;
    dfs(v, u);
    sz[u] += sz[v];
    if (sz[v] > sz[f[u]]) f[u] = v;
  }
}
void dfs2(int u, int fa) {
  for (int i = head[u]; i != -1; i = es[i].nxt) {
    int v = es[i].to;
    if (v == fa) continue;
    dfs2(v, u);
  }
  if (f[u] == 0) {
    g[u] = u;
  } else {
    int no = g[f[u]];
    while (!ck(u, no)) {
      no = father[no];
    }
    g[u] = no;
  }
}
int main(void) {
  scanf("%d%d", &n, &q);
  init();
  int p;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &p);
    addEdge(i, p);
    addEdge(p, i);
  }
  sz[0] = 0;
  dfs(1, 0);
  dfs2(1, 0);
  int v;
  while (q--) {
    scanf("%d", &v);
    printf("%d\n", g[v]);
  }
  return 0;
}
