#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 9, M = 1e2 + 3, MOD = 1e9 + 7;
const long long INF = 1e15;
vector<int> adj[N];
int sz[N], ans[N], mx[N], parent[N];
set<pair<int, int>> st[N];
void pre(int node, int par) {
  sz[node]++;
  parent[node] = par;
  for (auto it : adj[node]) {
    if (it == par) continue;
    pre(it, node);
    sz[node] += sz[it];
    st[node].insert({sz[it], it});
  }
}
void dfs(int node, int par) {
  int bigChild = -1;
  for (auto it : adj[node]) {
    if (it == par) continue;
    if (bigChild == -1 || sz[it] > sz[bigChild]) bigChild = it;
  }
  if (bigChild != -1) {
    dfs(bigChild, node);
    swap(st[bigChild], st[node]);
  }
  for (auto it : adj[node]) {
    if (it == par || it == bigChild) continue;
    dfs(it, node);
    for (auto elm : st[it]) st[node].insert(elm);
  }
  st[node].insert({sz[node], node});
  auto it = st[node].lower_bound({sz[node] / 2 + (sz[node] % 2), 0});
  if (it != st[node].end()) ans[node] = (*it).second;
}
void runtestcase() {
  int n, q, x;
  cin >> n >> q;
  ans[1] = 1;
  for (int i = 2; i <= n; ++i) {
    ans[i] = i;
    cin >> x;
    adj[i].push_back(x);
    adj[x].push_back(i);
  }
  pre(1, 1);
  dfs(1, 1);
  while (q--) {
    cin >> x;
    cout << ans[x] << '\n';
  }
}
int main() {
  cout << fixed << setprecision(6), ios::sync_with_stdio(false),
      cin.tie(nullptr), cout.tie(nullptr);
  int t = 1, tt = 1;
  while (t) {
    runtestcase();
    --t, ++tt;
  }
}
