#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
int tot, head[maxn << 1], n, m, a[maxn << 1], b, maxdep, xzynb, son[maxn << 1],
    size, ans[maxn << 1];
template <typename Tp>
inline void read(Tp& o) {
  o = 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') {
    o = (o << 1) + (o << 3) + (c ^ 48);
    c = getchar();
  }
  o *= f;
}
inline void print(int x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x > 9) {
    print(x / 10);
  }
  putchar(x % 10 + 48);
}
struct qwq {
  int to;
  int next;
} s[maxn << 1];
inline void add(int x, int y) {
  tot++;
  s[tot].to = y;
  s[tot].next = head[x];
  head[x] = tot;
}
inline void dfs(int x, int fa) {
  son[x] = 1;
  ans[x] = x;
  int res = 0;
  for (register int i = head[x]; i; i = s[i].next) {
    if (s[i].to != fa) {
      dfs(s[i].to, x);
      son[x] += son[s[i].to];
      if (son[s[i].to] > son[res]) res = s[i].to;
    }
  }
  if ((son[res] << 1) > son[x]) {
    int temp = ans[res];
    while (((son[x] - son[temp]) << 1) > son[x]) {
      temp = a[temp];
    }
    ans[x] = temp;
  }
}
int main() {
  read(n), read(m);
  for (register int i = 2; i <= n; ++i) {
    read(a[i]);
    add(i, a[i]), add(a[i], i);
  }
  dfs(1, 0);
  for (register int i = 1; i <= m; ++i) {
    read(b);
    print(ans[b]), puts("");
  }
  return 0;
}
