#include <bits/stdc++.h>
using namespace std;
int fa[409600], sz[409600], ans[409600];
vector<int> son[409600];
set<pair<int, int> > se;
set<pair<int, int> > dfs(int u) {
  set<pair<int, int> > se;
  sz[u] = 1;
  for (int i = 0; i < son[u].size(); i++) {
    set<pair<int, int> > res = dfs(son[u][i]);
    sz[u] += sz[son[u][i]];
    if (se.size() < res.size()) swap(se, res);
    for (set<pair<int, int> >::iterator it = res.begin(); it != res.end(); it++)
      se.insert(*it);
  }
  se.insert(make_pair(sz[u], u));
  ans[u] = se.lower_bound(make_pair(sz[u] / 2 + 1, -1))->second;
  return se;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  fa[0] = -1;
  for (int i = 1; i < n; i++) {
    scanf("%d", fa + i);
    fa[i]--;
    son[fa[i]].push_back(i);
  }
  dfs(0);
  while (m--) {
    int x;
    scanf("%d", &x);
    x--;
    printf("%d\n", ans[x] + 1);
  }
  return 0;
}
