#include <bits/stdc++.h>
using namespace std;
const int max_n = 300 * 1000;
int par[max_n];
vector<int> child[max_n];
int ans[max_n];
int size_of[max_n];
void dfs(int at) {
  size_of[at] = 1;
  for (int i = 0; i < (child[at].size()); i++) {
    dfs(child[at][i]);
    size_of[at] += size_of[child[at][i]];
  }
  const int n = size_of[at];
  int bad = -1;
  for (int i = 0; i < (child[at].size()); i++)
    if (2 * size_of[child[at][i]] > n) bad = child[at][i];
  if (bad == -1) {
    ans[at] = at;
    return;
  }
  int cur = ans[bad];
  while (2 * (n - size_of[cur]) > n) cur = par[cur];
  ans[at] = cur;
}
int main() {
  int n, q;
  cin >> n >> q;
  memset(par, -1, sizeof par);
  for (int i = (1); i < (n); i++) {
    cin >> par[i];
    par[i]--;
    child[par[i]].push_back(i);
  }
  dfs(0);
  while (q--) {
    int x;
    cin >> x;
    x--;
    cout << ans[x] + 1 << endl;
  }
  return 0;
}
