#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
struct Nod {
  int b, next;
  void init(int b, int next) {
    this->b = b;
    this->next = next;
  }
} buf[maxn];
int n, m, len, E[maxn];
int sz[maxn], msz[maxn], par[maxn][20];
int crd[maxn];
void init() {
  len = 0;
  memset(E, -1, sizeof(E));
  memset(crd, -1, sizeof(crd));
}
void add_Edge(int a, int b) {
  buf[len].init(b, E[a]);
  E[a] = len++;
}
void dfs(int u, int pre) {
  int i, v;
  sz[u] = 1;
  msz[u] = 0;
  par[u][0] = pre;
  for (i = E[u]; i != -1; i = buf[i].next) {
    v = buf[i].b;
    dfs(v, u);
    msz[u] = max(msz[u], sz[v]);
    sz[u] += sz[v];
  }
}
void preprocess() {
  int i, j;
  for (i = 1; i < 20; i++) {
    for (j = 1; j <= n; j++)
      par[j][i] = par[j][i - 1] != -1 ? par[par[j][i - 1]][i - 1] : -1;
  }
}
int getVet(int u, int len) {
  int i;
  for (i = 19; i >= 0; i--) {
    if (len >= (1 << i)) {
      u = par[u][i];
      len -= (1 << i);
      if (u == -1) return u;
    }
  }
  return u;
}
void sol() {
  int i, j, u, v;
  int lb, rb, mid;
  for (i = 1; i <= n; i++) {
    lb = -1, rb = n + 1;
    u = -1;
    while (rb - lb > 1) {
      mid = (lb + rb) >> 1;
      v = getVet(i, mid);
      if (v == -1 || 2 * msz[i] <= sz[v]) {
        rb = mid;
        u = v;
      } else
        lb = mid;
    }
    for (; u != -1 && 2 * (sz[u] - sz[i]) <= sz[u]; u = par[u][0]) {
      crd[u] = i;
    }
  }
}
int main() {
  int i, j, t;
  scanf("%d%d", &n, &m);
  init();
  for (i = 2; i <= n; i++) {
    scanf("%d", &t);
    add_Edge(t, i);
  }
  dfs(1, -1);
  preprocess();
  sol();
  while (m--) {
    scanf("%d", &t);
    printf("%d\n", crd[t]);
  }
  return 0;
}
