#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
struct Edge {
  int v, next;
} edge[N];
int head[N], tot, n, q;
void add(int u, int v) {
  edge[tot].v = v;
  edge[tot].next = head[u];
  head[u] = tot++;
}
int fa[N], sum[N], mxson[N];
void dfs_pre(int u) {
  sum[u] = 1;
  mxson[u] = 0;
  for (int i = head[u]; ~i; i = edge[i].next) {
    int v = edge[i].v;
    dfs_pre(v);
    sum[u] += sum[v];
    mxson[u] = max(mxson[u], sum[v]);
  }
}
int ret[N];
bool is_ret(int u, int v) {
  if (mxson[v] * 2 <= sum[u] && 2 * (sum[u] - sum[v]) <= sum[u]) return true;
  return false;
}
void dfs_ret(int u) {
  if (sum[u] == 1) {
    ret[u] = u;
    return;
  }
  int tmp = u;
  for (int i = head[u]; ~i; i = edge[i].next) {
    int v = edge[i].v;
    dfs_ret(v);
    if (mxson[u] == sum[v]) tmp = ret[v];
  }
  while (!is_ret(u, tmp)) {
    tmp = fa[tmp];
  }
  ret[u] = tmp;
}
int main() {
  scanf("%d%d", &n, &q);
  memset(head, -1, sizeof(head));
  for (int i = 2; i <= n; ++i) {
    int u, v = i;
    scanf("%d", &u);
    fa[i] = u;
    add(u, v);
  }
  dfs_pre(1);
  dfs_ret(1);
  for (int i = 1; i <= q; ++i) {
    int u;
    scanf("%d", &u);
    printf("%d\n", ret[u]);
  }
}
