#include <bits/stdc++.h>
using namespace std;
template <class tp>
tp F() {
  tp x = 0, ch = getchar(), f = 0;
  while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
template <class tp>
bool chkmax(tp &a, tp b) {
  return a < b ? a = b, 1 : 0;
}
template <class tp>
bool chkmin(tp &a, tp b) {
  return a > b ? a = b, 1 : 0;
}
inline void file_io(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
const int MAXN = 3e5 + 10;
int n, q, head[MAXN], nxt[MAXN << 1], pnt[MAXN << 1], fa[MAXN], son[MAXN],
    sz[MAXN], rt[MAXN];
int E;
inline void clear() {
  E = 0;
  memset(head, -1, sizeof(head));
}
inline void addedge(int x, int y) {
  nxt[E] = head[x];
  pnt[E] = y;
  head[x] = E++;
}
inline void dfs(int u) {
  sz[u] = 1;
  for (register int i = head[u]; i != -1; i = nxt[i]) {
    int v = pnt[i];
    dfs(v);
    sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
  if ((sz[son[u]] << 1) > sz[u]) {
    int x = rt[son[u]];
    while (((sz[u] - sz[x]) << 1) > sz[u]) x = fa[x];
    rt[u] = x;
  } else
    rt[u] = u;
}
int main() {
  scanf("%d%d", &n, &q);
  clear();
  for (register int i = 2; i <= n; ++i) {
    scanf("%d", &fa[i]);
    addedge(fa[i], i);
  }
  dfs(1);
  for (register int i = 1; i <= q; ++i) {
    int x;
    scanf("%d", &x);
    printf("%d\n", rt[x]);
  }
  return 0;
}
