#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int N = 3e5 + 5;
struct node {
  int v, next;
} e[N];
int fa[N], son[N], ans[N], head[N];
void dfs(int u) {
  ans[u] = u;
  son[u] = 1;
  for (int i = head[u]; i; i = e[i].next) {
    dfs(e[i].v);
    son[u] += son[e[i].v];
  }
  for (int i = head[u]; i; i = e[i].next)
    if (son[e[i].v] * 2 > son[u]) ans[u] = ans[e[i].v];
  while ((son[u] - son[ans[u]]) * 2 > son[u]) ans[u] = fa[ans[u]];
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &fa[i]);
    e[i - 1] = (node){i, head[fa[i]]};
    head[fa[i]] = i - 1;
  }
  dfs(1);
  for (int i = 0, a; i < q; i++) {
    scanf("%d", &a);
    printf("%d\n", ans[a]);
  }
  return 0;
}
