#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
int sz[N], par[N], cntrd[N];
vector<int> adj[N];
void dfs(int s, int p) {
  sz[s] = 1;
  int child_max = -1, child_id = -1;
  for (int nbr : adj[s]) {
    if (nbr != p) {
      dfs(nbr, s);
      sz[s] += sz[nbr];
      if (child_max < sz[nbr]) {
        child_max = sz[nbr];
        child_id = nbr;
      }
    }
  }
  if (child_id == -1) {
    cntrd[s] = s;
    return;
  }
  int curr = cntrd[child_id];
  while (sz[curr] < (sz[s] + 1) / 2) curr = par[curr];
  cntrd[s] = curr;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q;
  cin >> n >> q;
  int u;
  for (int i = 1; i < n; i++) {
    cin >> u;
    u--;
    par[i] = u;
    adj[i].push_back(u);
    adj[u].push_back(i);
  }
  dfs(0, -1);
  int v;
  while (q--) {
    cin >> v;
    cout << cntrd[v - 1] + 1 << '\n';
  }
  return 0;
}
