#include <bits/stdc++.h>
using namespace std;
template <typename qwq>
inline void read(qwq& x) {
  x = 0;
  register int f = 1;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  x *= f;
}
template <typename qaq>
inline void print(qaq x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
const int maxn = 300005;
struct edge {
  int v, next;
} e[maxn << 1];
int head[maxn], tot, son[maxn], n, q, fa[maxn];
inline void add(int x, int y) {
  ++tot;
  e[tot].v = y;
  e[tot].next = head[x];
  head[x] = tot;
}
int bignode, bigsize = 0x7f7f7f7f;
int ans[maxn];
inline void dfs(int x, int f) {
  register int res = 0;
  son[x] = 1;
  ans[x] = x;
  for (register int i = head[x]; i; i = e[i].next) {
    if (e[i].v == f) continue;
    dfs(e[i].v, x);
    son[x] += son[e[i].v];
    if (son[e[i].v] > son[res]) res = e[i].v;
  }
  if ((son[res] << 1) > son[x]) {
    register int temp = ans[res];
    while (((son[x] - son[temp]) << 1) > son[x]) temp = fa[temp];
    ans[x] = temp;
  }
}
int x, y, z;
int main() {
  read(n), read(q);
  for (register int i = 2; i <= n; ++i) {
    read(x), add(i, x), add(x, i), fa[i] = x;
  }
  dfs(1, 0);
  for (register int i = 1; i <= q; ++i) {
    read(x);
    print(ans[x]), puts("");
  }
}
