#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > s;
set<pair<int, int> >::iterator it;
int head[300010], to[300010], nxt[300010], pa[300010], cen[300010], cnt[300010],
    mxu[300010];
int dfs(int u) {
  cnt[u] = 1;
  for (int edge = head[u]; edge != -1; edge = nxt[edge]) {
    int v = to[edge];
    int tmp = dfs(v);
    cnt[u] += tmp;
    mxu[u] = max(mxu[u], tmp);
  }
  return cnt[u];
}
void dfs2(int u) {
  s.insert(pair<int, int>(cnt[u], u));
  it = s.lower_bound(pair<int, int>(2 * mxu[u], 0));
  if (it != s.end()) {
    while (it != s.end() && (*it).first <= 2 * cnt[u]) {
      int v = (*it).second;
      cen[v] = u;
      s.erase(*it);
      it = s.lower_bound(pair<int, int>(2 * mxu[u], 0));
    }
  }
  for (int edge = head[u]; edge != -1; edge = nxt[edge]) {
    int v = to[edge];
    dfs2(v);
  }
  s.erase(pair<int, int>(cnt[u], u));
}
int main() {
  int N, q, i;
  scanf("%d %d", &N, &q);
  memset(head, -1, sizeof(head));
  int edge = 0;
  for (i = 2; i <= N; i++) {
    scanf("%d", pa + i);
    nxt[edge] = head[pa[i]];
    to[edge] = i;
    head[pa[i]] = edge++;
  }
  dfs(1);
  dfs2(1);
  int u;
  while (q--) {
    scanf("%d", &u);
    printf("%d\n", cen[u]);
  }
  return 0;
}
