#include <bits/stdc++.h>
using namespace std;
int n, q;
int p[1000000];
vector<int> adj[1000000];
int cnt[1000000], cnt_child[1000000];
int med[1000000];
int cur_idx;
map<int, vector<int>> m;
set<pair<int, int>> s;
int dfs_cnt(int u) {
  if (cnt[u] != -1) return cnt[u];
  int total = 1;
  for (int v : adj[u]) total += dfs_cnt(v);
  return cnt[u] = total;
}
void dfs(int u) {
  s.insert({cnt[u], u});
  while (true) {
    auto it = s.lower_bound({2 * cnt_child[u], -1});
    if (it == s.end()) break;
    int pcnt = it->first;
    if (pcnt - cnt[u] > pcnt / 2) break;
    med[it->second] = u;
    s.erase(it);
  }
  for (int v : adj[u]) dfs(v);
}
void solve() {
  for (int i = 0; i < n; i++) cnt[i] = -1;
  for (int i = 0; i < n; i++)
    if (cnt[i] == -1) cnt[i] = dfs_cnt(i);
  for (int i = 0; i < n; i++) {
    cnt_child[i] = 0;
    for (int j : adj[i]) cnt_child[i] = max(cnt_child[i], cnt[j]);
  }
  dfs(0);
}
int main() {
  scanf("%d%d", &n, &q);
  p[0] = -1;
  for (int i = 1; i < n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
    adj[p[i]].push_back(i);
  }
  solve();
  while (q--) {
    int v;
    scanf("%d", &v);
    printf("%d\n", med[v - 1] + 1);
  }
}
