#include <bits/stdc++.h>
double eps = 1e-10;
using namespace std;
int mx[300005], ans[300005], cnt[300005], n, q, cent[300005], par[300005];
vector<int> g[300005];
void dfs(int v, int p = 0) {
  par[v] = p;
  int MAX = -1, center;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to == p) continue;
    dfs(to, v);
    if (MAX < cnt[to]) {
      MAX = cnt[to];
      center = ans[to];
    }
    cnt[v] += cnt[to];
    mx[v] = (mx[v] > cnt[to] ? mx[v] : cnt[to]);
  }
  cnt[v]++;
  if (cnt[v] == 1) center = v;
  while (1) {
    if (center == v) break;
    if (mx[center] >= cnt[v] - cnt[center]) {
      if (mx[center] * 2 <= cnt[v]) break;
    } else if ((cnt[v] - cnt[center]) * 2 <= cnt[v])
      break;
    center = par[center];
  }
  ans[v] = center;
}
int main() {
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    g[x].push_back(i);
    g[i].push_back(x);
  }
  dfs(1);
  for (int i = 1; i <= q; i++) {
    int t;
    scanf("%d", &t);
    printf("%d\n", ans[t]);
  }
}
