#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + c - '0';
  return x * f;
}
const long long N = 3e5 + 10;
long long n, q, son[N], edge, head[N], ans[N], f[N];
struct edge {
  long long to, net;
} e[N * 3];
bool ins[N];
inline void addedge(long long x, long long y) {
  e[++edge].to = x, e[edge].net = head[y], head[y] = edge;
}
void dfs(long long x) {
  ins[x] = son[x] = 1;
  ans[x] = x;
  long long Max = 0;
  for (long long i = head[x]; i; i = e[i].net)
    if (!ins[e[i].to]) {
      dfs(e[i].to);
      son[x] += son[e[i].to];
      if (son[e[i].to] > son[Max]) Max = e[i].to;
    }
  if (son[Max] * 2 > son[x]) {
    long long id = ans[Max];
    while (son[id] * 2 <= son[x]) id = f[id];
    ans[x] = id;
  }
}
int main() {
  n = read(), q = read();
  for (long long i = 2; i <= n; i++) addedge(i, f[i] = read());
  dfs(1);
  while (q--) printf("%lld\n", ans[read()]);
  return 0;
}
