#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int size[maxn], Max_Son_Size[maxn], centroid[maxn], fa[maxn];
vector<int> Q[maxn];
void dfs(int u) {
  int len = Q[u].size();
  size[u] = 1;
  Max_Son_Size[u] = 0;
  for (int i = 0; i < len; i++) {
    int v = Q[u][i];
    dfs(v);
    size[u] += size[v];
    Max_Son_Size[u] = max(Max_Son_Size[u], size[v]);
    fa[v] = u;
  }
}
int Is_Centroid(int u, int v) {
  if (Max_Son_Size[v] * 2 <= size[u] && (size[u] - size[v]) * 2 <= size[u]) {
    return 1;
  }
  return 0;
}
void solve(int u) {
  int len = Q[u].size();
  int p;
  for (int i = 0; i < len; i++) {
    int v = Q[u][i];
    if (Max_Son_Size[u] == size[v]) {
      p = v;
    }
    solve(v);
  }
  if (size[u] == 1) {
    centroid[u] = u;
  } else {
    p = centroid[p];
    while (!Is_Centroid(u, p)) {
      p = fa[p];
    }
    centroid[u] = p;
  }
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; i++) {
    int a;
    scanf("%d", &a);
    Q[a].push_back(i + 1);
  }
  dfs(1);
  solve(1);
  while (q--) {
    int a;
    scanf("%d", &a);
    printf("%d\n", centroid[a]);
  }
}
