#include <bits/stdc++.h>
using namespace std;
const int MOD(1000000007);
const int INF((1 << 30) - 1);
const int MAXN(300005);
vector<int> a[MAXN];
int num[MAXN], f[MAXN], ans[MAXN], child[MAXN];
void dfs(int node) {
  num[node] = 1;
  ans[node] = node;
  for (int i = 0; i < a[node].size(); i++) {
    int u = a[node][i];
    dfs(u);
    num[node] += num[u];
  }
  for (int i = 0; i < a[node].size(); i++) {
    int u = a[node][i];
    if (2 * num[u] > num[node]) {
      ans[node] = -1;
      child[node] = u;
    }
  }
}
void dfs2(int node) {
  if (ans[node] == -1) {
    vector<int> t;
    int u = node;
    while (ans[u] == -1) t.push_back(u), u = child[u];
    t.push_back(u);
    int j = 0;
    for (int i = 0; i < t.size(); i++) {
      while (j < t.size() && 2 * (num[t[i]] - num[t[j]]) <= num[t[i]]) j++;
      ans[t[i]] = t[j - 1];
    }
  }
  for (int i = 0; i < a[node].size(); i++) dfs2(a[node][i]);
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    a[x].push_back(i);
  }
  dfs(1);
  dfs2(1);
  while (q--) {
    int u;
    scanf("%d", &u);
    printf("%d\n", ans[u]);
  }
}
