#include <bits/stdc++.h>
using namespace std;
vector<int> tree[300001];
int cento[300001];
int sub[300001];
int maxCh[300001];
int n, q;
void dfs(int u, int p = -1) {
  sub[u] = 1;
  maxCh[u] = 0;
  for (int j = 0; j < tree[u].size(); ++j) {
    int v = tree[u][j];
    if (v == p) continue;
    dfs(v, u);
    sub[u] += sub[v];
    maxCh[u] = max(maxCh[u], sub[v]);
  }
}
set<pair<pair<int, int>, int> > merge(int u, int p = -1) {
  int sz = tree[u].size();
  if (sz == 1 && u != 0) {
    cento[u] = u;
    set<pair<pair<int, int>, int> > s;
    s.insert(make_pair(pair<int, int>(sub[u], maxCh[u]), u));
    return s;
  }
  int bigCh = -1;
  int maxsz = -1;
  for (int j = 0; j < tree[u].size(); ++j) {
    int v = tree[u][j];
    if (v == p) continue;
    if (maxsz < sub[v]) {
      maxsz = sub[v];
      bigCh = v;
    }
  }
  set<pair<pair<int, int>, int> > s = merge(bigCh, u);
  for (int j = 0; j < tree[u].size(); ++j) {
    int v = tree[u][j];
    if (v == p || v == bigCh) continue;
    set<pair<pair<int, int>, int> > tmp = merge(v, u);
    for (set<pair<pair<int, int>, int> >::iterator it = tmp.begin();
         it != tmp.end(); ++it) {
      s.insert(*it);
    }
  }
  s.insert(make_pair(pair<int, int>(sub[u], maxCh[u]), u));
  int x = sub[u] >> 1;
  ;
  if (sub[u] & 1) ++x;
  set<pair<pair<int, int>, int> >::iterator it =
      s.lower_bound(make_pair(pair<int, int>(x, 0), 0));
  cento[u] = it->second;
  return s;
}
int main() {
  scanf("%d %d", &n, &q);
  int v = 0;
  for (int i = 1; i < n; ++i) {
    scanf("%d", &v);
    --v;
    tree[i].push_back(v);
    tree[v].push_back(i);
  }
  memset(cento, -1, sizeof(cento));
  dfs(0, -1);
  for (int i = 0; i < n; ++i) {
    --sub[i];
  }
  merge(0, -1);
  while (q--) {
    int u;
    scanf("%d", &u);
    --u;
    printf("%d\n", cento[u] + 1);
  }
}
