#include <bits/stdc++.h>
using namespace std;
long long t, n, m, u, v, q, r, ql, qr, k, l, s, w, z, d, b, p;
const int N = 3e5 + 500;
;
const int LN = 19;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 52LL;
int centroid[N];
int L[N][LN];
vector<int> adj[N];
int D[N];
int sz[N];
int K[N];
void dfs(int v, int d) {
  D[v] = d;
  sz[v] = 1;
  K[v] = 0;
  for (int u : adj[v]) {
    dfs(u, d + 1);
    L[u][0] = v;
    sz[v] += sz[u];
    K[v] = max(K[v], sz[u]);
  }
}
void pre() {
  for (int j = 1; j < LN; ++j)
    for (int i = 1; i <= n; ++i) L[i][j] = L[L[i][j - 1]][j - 1];
}
int bb[1 << LN];
int find(int v, int f) {
  while (f) {
    v = L[v][bb[f & -f]];
    f -= (f & -f);
  }
  return v;
}
vector<pair<int, int> > e[N];
pair<int, int> dfs2(int v) {
  pair<int, int> g = make_pair(INT_MAX, 0);
  for (pair<int, int> u : e[v]) g = min(u, g);
  for (int u : adj[v]) {
    g = min(g, dfs2(u));
  }
  if (g.first != INT_MAX && g.first <= D[v]) centroid[v] = g.second;
  return g;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    cin >> u;
    adj[u].push_back(i);
  }
  for (int i = 0; i < LN; ++i) bb[1 << i] = i;
  dfs(1, 0);
  pre();
  for (int i = 1; i <= n; ++i) {
    int lo = 0, hi = D[i] + 1;
    while (lo < hi) {
      int mid = (lo + hi) / 2;
      int x = find(i, mid);
      if ((sz[x]) / 2 < K[i])
        lo = mid + 1;
      else
        hi = mid;
    }
    int x = lo;
    lo = 0, hi = D[i];
    while (lo < hi) {
      int mid = (lo + hi + 1) / 2;
      int x = find(i, mid);
      if (sz[x] - sz[i] > (sz[x] / 2))
        hi = mid - 1;
      else
        lo = mid;
    }
    if (D[i] - lo > D[i] - x) continue;
    e[find(i, x)].push_back(make_pair(D[i] - lo, i));
  }
  dfs2(1);
  while (q--) {
    cin >> v;
    cout << centroid[v] << '\n';
  }
  return 0;
}
