#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, q;
vector<int> g[N];
int subsum[N];
int cent[N];
int pa[N];
void calcSum(int u) {
  subsum[u]++;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    calcSum(v);
    subsum[u] += subsum[v];
  }
}
void dfs(int u) {
  int pos = u;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    dfs(v);
    if (subsum[v] * 2 > subsum[u]) {
      pos = v;
    }
  }
  if (pos == u) {
    cent[u] = u;
    return;
  }
  int v = cent[pos];
  while (v != u) {
    if (subsum[v] * 2 > subsum[u]) {
      cent[u] = v;
      return;
    }
    v = pa[v];
  }
}
int main() {
  std::cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    g[x].push_back(i);
    pa[i] = x;
  }
  calcSum(1);
  dfs(1);
  while (q--) {
    int x;
    cin >> x;
    cout << cent[x] << endl;
  }
  return 0;
}
