#include <bits/stdc++.h>
const int INF = 1 << 30;
const int mod = 1e9 + 3;
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  long long f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  x *= f;
  return;
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  return;
}
inline long long qpow(long long a, long long b) {
  long long x = 1, y = a;
  while (b >= 1) {
    if (b % 2 == 1) x = x * y % mod;
    y = y * y % mod;
    b /= 2;
  }
  return x;
}
int n, m, q[300005], ans[300005], fa[300005], son[300005];
struct fuck {
  int next, to;
} you[1000005];
int head[300005];
int tot = 0;
inline void add(int u, int v) {
  tot++;
  you[tot].to = v;
  you[tot].next = head[u];
  head[u] = tot;
}
inline void dfs(int x, int Fa) {
  int res = 0;
  son[x] = 1;
  ans[x] = x;
  for (int i = head[x]; i; i = you[i].next) {
    if (you[i].to == Fa) continue;
    dfs(you[i].to, x);
    son[x] += son[you[i].to];
    if (son[you[i].to] > son[res]) {
      res = you[i].to;
    }
  }
  if ((son[res] << 1) > son[x]) {
    int temp = ans[res];
    while (((son[x] - son[temp]) << 1) > son[x]) temp = fa[temp];
    ans[x] = temp;
  }
}
int main() {
  read(n), read(m);
  for (long long i = (2); i <= (n); i++) {
    read(q[i]);
    add(i, q[i]);
    add(q[i], i);
    fa[i] = q[i];
  }
  dfs(1, 0);
  int x;
  for (long long i = (1); i <= (m); i++) {
    read(x);
    write(ans[x]);
    puts("");
  }
}
