#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> tree;
vector<long long> sz;
vector<long long> centroid;
map<long long, long long> dfs(long long curr) {
  map<long long, long long> mp;
  sz[curr] = 1;
  for (long long i : tree[curr]) {
    map<long long, long long> temp = dfs(i);
    sz[curr] = sz[curr] + sz[i];
    if ((long long)temp.size() > (long long)mp.size()) swap(temp, mp);
    for (auto j : temp) {
      mp[j.first] = j.second;
    }
  }
  mp[sz[curr]] = curr;
  auto it = mp.lower_bound(ceil(1.0 * sz[curr] / 2));
  if (it == mp.end()) it--;
  centroid[curr] = it->second;
  return mp;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, q;
  cin >> n >> q;
  tree.resize(n);
  sz.resize(n);
  centroid.resize(n);
  for (long long i = 1; i < n; i++) {
    long long p;
    cin >> p;
    p--;
    tree[p].push_back(i);
  }
  map<long long, long long> all = dfs(0);
  for (long long i = 0; i < q; i++) {
    long long node;
    cin >> node;
    node--;
    cout << centroid[node] + 1 << "\n";
  }
  return 0;
}
