#include <bits/stdc++.h>
using std::vector;
const int maxn = 4e5 + 1;
int siz[maxn], fa[maxn], n, q, a, b, pos, g[maxn], G[maxn], ans[maxn],
    mxs[maxn];
struct Edge {
  int u, v;
} e[maxn << 1];
int head[maxn], ecnt;
inline void addedge(int u, int v) {
  e[++ecnt].v = v;
  e[ecnt].u = head[u];
  head[u] = ecnt;
}
inline int get(int x, int POS) { return std::max(mxs[POS], siz[x] - siz[POS]); }
inline void dfs(int x) {
  siz[x] = 1;
  ans[x] = x;
  for (int i = head[x], v; i && (v = e[i].v); i = e[i].u) {
    dfs(v);
    siz[x] += siz[v];
    mxs[x] = std::max(mxs[x], siz[v]);
  }
  for (int i = head[x], v; i && (v = e[i].v); i = e[i].u) {
    int now = ans[v];
    while (1) {
      if (now == x) break;
      if (get(x, now) >= get(x, fa[now]))
        now = fa[now];
      else
        break;
    }
    if (get(x, now) <= get(x, ans[x])) ans[x] = now;
  }
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 2; i <= n; i++) scanf("%d", &fa[i]), addedge(fa[i], i);
  dfs(1);
  for (int i = 1; i <= q; i++) {
    scanf("%d", &a);
    printf("%d\n", ans[a]);
  }
}
