#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e5 + 11;
int n, q;
int centroid[MAX];
vector<int> graf[MAX];
set<pair<int, int> > solve(int v) {
  set<pair<int, int> > ret;
  for (auto u : graf[v]) {
    auto tmp = solve(u);
    if (tmp.size() > ret.size()) swap(tmp, ret);
    for (auto it : tmp) ret.insert(it);
  }
  int ret_size = ret.size() + 1;
  ret.emplace(ret_size, v);
  centroid[v] = ret.lower_bound(make_pair((ret_size + 1) / 2, 0))->second;
  return move(ret);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> q;
  int v;
  for (int i = 1; i < n; ++i) {
    cin >> v;
    graf[--v].push_back(i);
  }
  solve(0);
  for (int i = 0; i < q; ++i) {
    cin >> v;
    cout << centroid[--v] + 1 << endl;
  }
  return 0;
}
