#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 1;
int n, q;
int ans[N];
set<pair<int, int> > sum[N];
vector<int> adj[N];
void input() {
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    int v;
    cin >> v;
    adj[v].push_back(i);
  }
}
int dfs(int u) {
  int cnt = 1;
  for (int v : adj[u]) {
    cnt += dfs(v);
    if (sum[u].size() < sum[v].size()) {
      swap(sum[u], sum[v]);
    }
    sum[u].insert(sum[v].begin(), sum[v].end());
    sum[v].clear();
  }
  sum[u].insert({cnt, u});
  ans[u] = sum[u].upper_bound(pair<int, int>(cnt / 2, N))->second;
  return cnt;
}
void solve() {
  dfs(1);
  for (int i = 0; i < q; ++i) {
    int u;
    cin >> u;
    cout << ans[u] << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  input();
  solve();
}
