#include <bits/stdc++.h>
using namespace std;
vector<int> g[3000010];
int ans[3000010], w[3000010], par[3000010], heavyn[3000010];
void dfs(int node) {
  int i, heavyw = 0, v;
  w[node] = 1;
  for (i = 0; i < g[node].size(); i++) {
    v = g[node][i];
    dfs(v);
    if (w[v]) {
      w[node] += w[v];
      if (w[v] > heavyw) {
        heavyw = w[v];
        heavyn[node] = v;
      }
    }
  }
  int sz = w[node] / 2;
  if (heavyn[node] == 0 || heavyw <= sz) {
    ans[node] = node;
    return;
  }
  int temp = ans[heavyn[node]], flag;
  while (temp != node) {
    if (w[heavyn[temp]] <= sz && (w[node] - w[temp] <= sz)) {
      ans[node] = temp;
      return;
    }
    temp = par[temp];
  }
}
int main() {
  int n, q, i, num;
  scanf("%d %d", &n, &q);
  for (i = 2; i <= n; i++) {
    scanf("%d", &num);
    par[i] = num;
    g[num].push_back(i);
  }
  dfs(1);
  while (q--) {
    scanf("%d", &num);
    printf("%d\n", ans[num]);
  }
  return 0;
}
