#include <bits/stdc++.h>
using namespace std;
vector<int> v[300005];
int ans[300005], Size[300005], f[300005];
int dfs(int now) {
  if (v[now].size() == 0) {
    ans[now] = now;
    Size[now] = 1;
    return 1;
  }
  int s = 1, mx = 0, t = 0;
  for (int i = 0; i < v[now].size(); i++) {
    int x = dfs(v[now][i]);
    s += x;
    if (x > mx) {
      mx = x;
      t = v[now][i];
    }
  }
  Size[now] = s;
  ans[now] = ans[t];
  while (ans[now] != now && Size[ans[now]] - 1 < Size[now] - Size[ans[now]]) {
    ans[now] = f[ans[now]];
  }
  return Size[now];
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &f[i]);
    v[f[i]].push_back(i);
  }
  dfs(1);
  for (int i = 1; i <= q; i++) {
    int temp;
    scanf("%d", &temp);
    printf("%d\n", ans[temp]);
  }
}
