#include <bits/stdc++.h>
using namespace std;
struct node {
  int v, next;
} edge[300005];
int cnt, head[300005];
int n, q;
int size[300005], son[300005], fa[300005];
int ans[300005];
void add_edge(int u, int v) {
  edge[cnt].v = v, edge[cnt].next = head[u], head[u] = cnt++;
}
void dfs(int u) {
  size[u] = 1;
  int Max = 0;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].v;
    dfs(v);
    if (size[v] > Max) {
      Max = size[v];
      son[u] = v;
    }
    size[u] += size[v];
  }
  if (son[u] == -1) {
    ans[u] = u;
    return;
  }
  int center = ans[son[u]];
  while ((size[u] - size[center]) * 2 > size[u]) {
    center = fa[center];
  }
  ans[u] = center;
}
int main() {
  cin >> n >> q;
  cnt = 0;
  memset(head, -1, sizeof head);
  for (int i = 2; i <= n; i++) {
    int v;
    scanf("%d", &v);
    add_edge(v, i);
    fa[i] = v;
  }
  memset(son, -1, sizeof son);
  dfs(1);
  while (q--) {
    int u;
    scanf("%d", &u);
    printf("%d\n", ans[u]);
  }
  return 0;
}
