#include <bits/stdc++.h>
using namespace std;
const int N = 1008611;
struct edge {
  int to, next;
} e[N << 1];
int e_tot, head[N];
int n, q;
int zx[N], maxson[N], sontot[N];
int rfa[N];
inline void edge_add(int x, int y) {
  ++e_tot, e[e_tot].to = y, e[e_tot].next = head[x], head[x] = e_tot;
}
inline void dfs(int now, int las) {
  rfa[now] = las;
  sontot[now] = 1;
  for (register int i = head[now]; i; i = e[i].next)
    if (e[i].to != las) {
      dfs(e[i].to, now);
      sontot[now] += sontot[e[i].to];
      maxson[now] = max(maxson[now], sontot[e[i].to]);
    }
  int maxn = 0, maxp = 0;
  for (register int i = head[now]; i; i = e[i].next)
    if (e[i].to != las)
      if (sontot[e[i].to] * 2 > sontot[now] && sontot[e[i].to] > maxn)
        maxn = sontot[e[i].to], maxp = e[i].to;
  if (maxp != 0 && zx[maxp] != 0) {
    int emm = zx[maxp];
    while ((sontot[now] - sontot[emm]) * 2 > sontot[now]) {
      emm = rfa[emm];
    }
    zx[now] = emm;
  }
}
int main() {
  int invar1;
  scanf("%d%d", &n, &q);
  zx[1] = 1;
  for (register int i = 2; i <= n; ++i)
    scanf("%d", &invar1), edge_add(invar1, i), zx[i] = i;
  dfs(1, 1);
  for (register int i = 1; i <= q; ++i)
    scanf("%d", &invar1), printf("%d\n", zx[invar1]);
  return 0;
}
