#include <bits/stdc++.h>
using namespace std;
const int L = 3e5 + 5;
vector<int> ad[L];
int mx[L], ans[L], S[L], P[L];
void dfs(int x) {
  for (int i = 0; i < (int)((int)(ad[x]).size()); ++i) {
    dfs(ad[x][i]);
    if (S[ad[x][i]] > S[mx[x]]) mx[x] = ad[x][i];
    S[x] += S[ad[x][i]];
  }
  S[x]++;
  if (S[x] == 1) {
    ans[x] = x;
    return;
  }
  int c = ans[mx[x]];
  while (S[c] <= S[x] / 2 && c != 1) c = P[c];
  ans[x] = c;
}
int main() {
  std::ios::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  int u;
  for (int i = 2; i <= N; ++i) cin >> P[i], ad[P[i]].push_back(i);
  dfs(1);
  while (Q--) cin >> u, cout << ans[u] << endl;
  return 0;
}
