#include <bits/stdc++.h>
using namespace std;
int p[300005], n, q, sz[300005];
vector<int> gr[300005];
int ans[300005];
void go(int now) {
  sz[now] = 1;
  for (int i = 0; i < gr[now].size(); i++) {
    go(gr[now][i]);
    sz[now] += sz[gr[now][i]];
  }
}
void calc(int now) {
  int base = -1;
  for (int i = 0; i < gr[now].size(); i++) {
    int u = gr[now][i];
    calc(u);
    if (sz[u] >= ceil(sz[now] / 2.0)) base = u;
  }
  if (base == -1) {
    ans[now] = now;
    return;
  }
  int t = ans[base];
  while (sz[t] < ceil(sz[now] / 2.0)) t = p[t];
  ans[now] = t;
}
int main() {
  int i, j;
  scanf("%d", &n);
  scanf("%d", &q);
  for (i = 2; i <= n; i++) {
    scanf("%d", &p[i]);
    gr[p[i]].push_back(i);
  }
  go(1);
  calc(1);
  while (q--) {
    int a;
    scanf("%d", &a);
    printf("%d\n", ans[a]);
  }
}
