#include <bits/stdc++.h>
using namespace std;
set<pair<int, int>> dfs(vector<vector<int>> &g, vector<int> &centroid,
                        vector<int> &sz, int v) {
  set<pair<int, int>> s;
  sz[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    auto c_ans = dfs(g, centroid, sz, g[v][i]);
    if (c_ans.size() > s.size()) swap(c_ans, s);
    s.insert(c_ans.begin(), c_ans.end());
    sz[v] += sz[g[v][i]];
  }
  auto it = s.lower_bound(make_pair((sz[v] + 1) / 2, 0));
  if (it != s.end()) {
    centroid[v] = it->second;
  } else {
    centroid[v] = v;
  }
  s.insert(make_pair(sz[v], v));
  return s;
}
int main() {
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<vector<int>> g(n);
  for (int i = 1; i <= n - 1; i++) {
    int p;
    cin >> p;
    g[p - 1].push_back(i);
  }
  vector<int> sz(n);
  vector<int> centroid(n);
  dfs(g, centroid, sz, 0);
  for (int i = 0; i < q; i++) {
    int v;
    cin >> v;
    cout << (centroid[v - 1] + 1) << "\n";
  }
  return 0;
}
