#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
const int inf = 1e9 + 7;
vector<int> edge[N];
pair<int, int> sub[N];
int sz[N];
int note[N];
int cnt;
int n, q;
vector<pair<int, int> > st[N * 4];
void add_edge(int x, int y) {
  edge[x].push_back(y);
  edge[y].push_back(x);
}
void dfs(int u, int p) {
  sub[u].first = ++cnt;
  note[cnt] = u;
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i];
    if (v == p) continue;
    dfs(v, u);
    sz[u] += sz[v];
  }
  sub[u].second = cnt;
  sz[u] += 1;
}
void build(int p, int l, int r) {
  if (l == r) {
    st[p].push_back(make_pair(sz[note[l]], note[l]));
    return;
  }
  int mid = (l + r) / 2;
  build(p * 2, l, mid);
  build(p * 2 + 1, mid + 1, r);
  st[p].resize(st[p * 2].size() + st[p * 2 + 1].size());
  merge(st[p * 2].begin(), st[p * 2].end(), st[p * 2 + 1].begin(),
        st[p * 2 + 1].end(), st[p].begin());
}
pair<int, int> get(int p, int l, int r, int L, int R, int x) {
  if (l > R || r < L) return make_pair(inf, inf);
  if (L <= l && r <= R) {
    vector<pair<int, int> >::iterator it =
        lower_bound(st[p].begin(), st[p].end(), make_pair(x, -1));
    if (it == st[p].end()) return make_pair(inf, inf);
    return *it;
  }
  int mid = (l + r) / 2;
  pair<int, int> left = get(p * 2, l, mid, L, R, x);
  pair<int, int> right = get(p * 2 + 1, mid + 1, r, L, R, x);
  return (left.first < right.first) ? left : right;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    add_edge(x, i);
  }
  dfs(1, 0);
  build(1, 1, n);
  while (q--) {
    int v;
    cin >> v;
    pair<int, int> res =
        get(1, 1, n, sub[v].first, sub[v].second, (sz[v] + 1) / 2);
    cout << res.second << "\n";
  }
  return 0;
}
