#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000 + 100;
int p[maxn << 2];
void pushdown(int L, int R, int u) {
  if (L != R) {
    if (p[u] != -1) {
      p[u << 1] = p[u];
      p[u << 1 | 1] = p[u];
      p[u] = -1;
    }
  }
}
void update(int cL, int cR, int val, int L, int R, int u) {
  pushdown(L, R, u);
  if (cL <= L && R <= cR) {
    p[u] = val;
  } else {
    int m = (L + R) / 2;
    if (cR <= m)
      update(cL, cR, val, L, m, u << 1);
    else if (cL > m)
      update(cL, cR, val, m + 1, R, u << 1 | 1);
    else {
      update(cL, cR, val, L, m, u << 1);
      update(cL, cR, val, m + 1, R, u << 1 | 1);
      update(cL, cR, val, m + 1, R, u << 1 | 1);
    }
  }
}
int query(int x, int L, int R, int u) {
  pushdown(L, R, u);
  if (L == R)
    return p[u];
  else {
    int m = (L + R) / 2;
    if (x <= m)
      return query(x, L, m, u << 1);
    else
      return query(x, m + 1, R, u << 1 | 1);
  }
}
vector<int> G[maxn];
int res[maxn];
int sum[maxn];
int n;
void dfs(int u) {
  sum[u]++;
  int Max = 0;
  for (int i = 0; i < G[u].size(); ++i) {
    int v = G[u][i];
    dfs(v);
    sum[u] += sum[v];
    Max = max(Max, sum[v]);
  }
  update(Max, sum[u], u, 0, n, 1);
  res[u] = query(sum[u] / 2, 0, n, 1);
}
int main() {
  int q;
  scanf("%d %d", &n, &q);
  for (int i = 2; i <= n; ++i) {
    int t;
    scanf("%d", &t);
    G[t].push_back(i);
  }
  memset(p, -1, sizeof(p));
  memset(sum, 0, sizeof(sum));
  dfs(1);
  while (q--) {
    int t;
    scanf("%d", &t);
    printf("%d\n", res[t]);
  }
  return 0;
}
