#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 200;
inline void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
struct Front_Star {
  int u, v, nxt;
} e[N << 2];
int cnt = 0;
int first[N];
void add(int u, int v) {
  ++cnt;
  e[cnt].u = u;
  e[cnt].v = v;
  e[cnt].nxt = first[u];
  first[u] = cnt;
}
int fa[N];
int siz[N];
int root[N];
int Mxsiz[N];
void DFS(int u, int fat) {
  siz[u] = 1;
  fa[u] = fat;
  int pre = 0;
  int rt = u;
  for (int i = first[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fat) continue;
    DFS(v, u);
    siz[u] += siz[v];
    pre = max(pre, siz[v]);
  }
  Mxsiz[u] = pre;
  for (int i = first[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fat || siz[v] < (siz[u] + 1) / 2) continue;
    int now = root[v];
    int sumnow = max(Mxsiz[now], siz[u] - siz[now]);
    int p = now;
    now = fa[now];
    for (; now != u; now = fa[now]) {
      int sum = max(Mxsiz[now], siz[u] - siz[now]);
      if (sum < sumnow) {
        sumnow = sum;
        p = now;
      } else
        break;
    }
    if (sumnow < pre) {
      pre = sumnow;
      rt = p;
    }
  }
  root[u] = rt;
}
int n, Q;
int main() {
  read(n);
  read(Q);
  for (int i = 2; i <= n; ++i) {
    int x;
    read(x);
    add(x, i);
    add(i, x);
  }
  DFS(1, 0);
  while (Q--) {
    int x;
    read(x);
    cout << root[x] << '\n';
  }
  return 0;
}
