#include <bits/stdc++.h>
using namespace std;
const double EPS = 0.00000001;
const long long mod = 1000000000 + 7;
using namespace std;
vector<int> g[300010];
int cnt[300010], a[300010], pr[300010], lr[300010];
int dfs(int s) {
  int ans = 1;
  for (auto u : g[s]) {
    ans += dfs(u);
  }
  return cnt[s] = ans;
}
void h(int s) {
  int ans = 0;
  for (auto u : g[s]) {
    ans = max(cnt[u], ans);
  }
  lr[s] = ans;
}
int f(int s) {
  if (a[s] != -1) return a[s];
  int ans = -1;
  int fnd = 0, v = -1;
  for (auto u : g[s]) {
    if (2 * cnt[u] > cnt[s]) {
      fnd = 1, v = u;
    }
  }
  if (fnd) {
    int u = f(v);
    int res = u;
    while ((cnt[s] - cnt[u]) * 2 > cnt[s]) u = pr[u];
    ans = u;
  } else
    ans = s;
  return a[s] = ans;
}
int main() {
  ios::sync_with_stdio(0);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n - 1; i++) {
    int p;
    cin >> p;
    g[p - 1].push_back(i + 1);
    pr[i + 1] = p - 1;
  }
  memset(a, -1, sizeof(a));
  dfs(0);
  for (int i = 0; i < n; i++) h(i);
  for (int i = 0; i < n; i++) f(i);
  int u;
  while (q--) {
    cin >> u;
    cout << a[u - 1] + 1 << '\n';
  }
  int _________________________;
  cin >> _________________________;
  return 0;
}
