#include <bits/stdc++.h>
using namespace std;
int head[(300000 + 500)], tot = 0, T, ans[(300000 + 500)], n,
                          fa[(300000 + 500)], sz[(300000 + 500)];
struct edge {
  int to, nxt;
} e[(300000 + 500) << 1];
void addedge(int u, int v) { e[++tot] = (edge){v, head[u]}, head[u] = tot; }
void dfs(int u) {
  sz[u] = 1, ans[u] = u;
  for (int i = head[u], v; i; i = e[i].nxt) v = e[i].to, dfs(v), sz[u] += sz[v];
  for (int i = head[u]; i; i = e[i].nxt)
    if (sz[e[i].to] * 2 > sz[u]) ans[u] = ans[e[i].to];
  while ((sz[u] - sz[ans[u]]) * 2 > sz[u]) ans[u] = fa[ans[u]];
}
int main() {
  scanf("%d%d", &n, &T);
  for (int i = 2; i <= n; ++i) scanf("%d", &fa[i]), addedge(fa[i], i);
  dfs(1);
  while (T--) {
    int u;
    scanf("%d", &u);
    printf("%d\n", ans[u]);
  }
  return 0;
}
