#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (1 << 20);
const int N = (1 << 20);
int n, was[MAX_N], sz[MAX_N], timer;
pair<int, int> t[MAX_N], a[2 * N];
vector<int> g[MAX_N];
vector<pair<int, int> > tr[2 * N];
int dfs(int v) {
  was[v] = 1;
  sz[v] = 1;
  t[v].first = ++timer;
  for (int u : g[v]) {
    if (!was[u]) {
      int res = dfs(u);
      sz[v] += res;
    }
  }
  t[v].second = ++timer;
  a[t[v].first] = make_pair(sz[v], v);
  return sz[v];
}
void build(int v, int tl, int trr) {
  if (tl > trr) {
    return;
  }
  if (tl == trr) {
    if (a[tl].first) tr[v].push_back(a[tl]);
    return;
  }
  int tm = (tl + trr) / 2;
  build(v * 2, tl, tm);
  build(v * 2 + 1, tm + 1, trr);
  tr[v].resize(tr[v * 2].size() + tr[v * 2 + 1].size());
  merge(tr[v * 2].begin(), tr[v * 2].end(), tr[v * 2 + 1].begin(),
        tr[v * 2 + 1].end(), tr[v].begin());
}
pair<int, int> get(int v, int tl, int trr, int L, int R, pair<int, int> Q) {
  if (L > trr || tl > R) return make_pair(INT_MAX, INT_MAX);
  if (L <= tl && trr <= R) {
    auto it = lower_bound(tr[v].begin(), tr[v].end(), Q);
    if (it == tr[v].end())
      return make_pair(INT_MAX, INT_MAX);
    else
      return *it;
  }
  int tm = (tl + trr) / 2;
  return min(get(v * 2, tl, tm, L, R, Q), get(v * 2 + 1, tm + 1, trr, L, R, Q));
}
int main() {
  int q, v;
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &v);
    g[v].push_back(i);
    g[i].push_back(v);
  }
  dfs(1);
  build(1, 1, MAX_N);
  while (q--) {
    scanf("%d", &v);
    printf("%d\n", get(1, 1, MAX_N, t[v].first, t[v].second,
                       make_pair((sz[v] + 1) / 2, 0))
                       .second);
  }
  return 0;
}
