#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > vec;
vector<vector<pair<int, int> > > tree;
vector<int> in, out, sz;
vector<pair<int, int> > seg;
int tim = 0;
int dfs(int s, int p) {
  sz[s] = 1;
  in[s] = tim;
  for (auto i : vec[s])
    if (i != p) {
      tim++;
      sz[s] += dfs(i, s);
    }
  out[s] = tim;
  return sz[s];
}
void dfs1(int s, int p) {
  seg.push_back({sz[s], s});
  for (auto i : vec[s])
    if (i != p) dfs1(i, s);
}
bool compare(pair<int, int> p1, pair<int, int> p2) {
  return p1.first < p2.first;
}
vector<pair<int, int> > build(int s, int e, int idx) {
  if (s == e) {
    tree[idx].push_back(seg[s]);
    return tree[idx];
  }
  int mid = (s + e) / 2;
  vector<pair<int, int> > v1 = build(s, mid, 2 * idx);
  vector<pair<int, int> > v2 = build(mid + 1, e, 2 * idx + 1);
  tree[idx].resize(v1.size() + v2.size());
  merge(v1.begin(), v1.end(), v2.begin(), v2.end(), tree[idx].begin(), compare);
  return tree[idx];
}
pair<int, int> query(int s, int e, int l, int r, int idx, int x) {
  if (l > e || r < s) return {INT_MAX, INT_MAX};
  if (l <= s && r >= e) {
    auto it = lower_bound(tree[idx].begin(), tree[idx].end(),
                          pair<int, int>(x, INT_MIN), compare);
    if (it != tree[idx].end())
      return *it;
    else
      return {INT_MAX, INT_MAX};
  }
  int mid = (s + e) / 2;
  pair<int, int> ans1 = query(s, mid, l, r, 2 * idx, x);
  pair<int, int> ans2 = query(mid + 1, e, l, r, 2 * idx + 1, x);
  return min(ans1, ans2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  vec.resize(n + 1);
  in.resize(n + 1);
  out.resize(n + 1);
  sz.resize(n + 1);
  for (int i = 2; i <= n; i++) {
    int u;
    cin >> u;
    vec[u].push_back(i);
    vec[i].push_back(u);
  }
  dfs(1, 0);
  dfs1(1, 0);
  tree.resize(4 * seg.size() + 1);
  build(0, seg.size() - 1, 1);
  while (q--) {
    int x;
    pair<int, int> ans;
    cin >> x;
    int qr = sz[x];
    if (qr & 1)
      ans = query(0, seg.size() - 1, in[x], out[x], 1, qr / 2 + 1);
    else
      ans = query(0, seg.size() - 1, in[x], out[x], 1, qr / 2 + 1);
    cout << ans.second << "\n";
  }
}
