#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n, q, pnt[N], cnt[N], mx[N], f[N];
vector<int> ed[N];
void add(int u, int fa) {
  pnt[u] = fa;
  ed[fa].push_back(u);
}
void dfs(int u, int fa) {
  pnt[u] = fa;
  int sz = ed[u].size();
  int id = 0;
  for (int i = 0; i < sz; i++) {
    int to = ed[u][i];
    if (to == fa) continue;
    dfs(to, u);
    cnt[u] += cnt[to];
    if (cnt[to] > mx[u]) {
      mx[u] = cnt[to];
      id = to;
    }
  }
  if (mx[u] * 2 < cnt[u])
    f[u] = u;
  else {
    int num = f[id];
    while (pnt[num] && max(mx[num], cnt[u] - cnt[num]) >
                           max(mx[pnt[num]], cnt[u] - cnt[pnt[num]]))
      num = pnt[num];
    f[u] = num;
  }
}
int main() {
  int fa;
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &fa);
    add(i, fa);
  }
  pnt[1] = 1;
  for (int i = 1; i <= n; i++) cnt[i] = 1;
  dfs(1, 0);
  while (q--) {
    int pin;
    scanf("%d", &pin);
    printf("%d\n", f[pin]);
  }
  return 0;
}
