#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, sz[maxn], q, deep[maxn], fa[maxn], k[maxn], p[maxn];
vector<int> g[maxn];
int work(int t, int rt) {
  while (t != rt) {
    if (sz[rt] - sz[t] >= sz[t])
      t = fa[t];
    else
      break;
  }
  return t;
}
void dfs(int u, int f) {
  sz[u] = 1, fa[u] = f;
  k[u] = u;
  for (int i = 0; i < g[u].size(); i++) {
    int it = g[u][i];
    if (it == f) continue;
    deep[it] = deep[u] + 1;
    dfs(it, u);
    sz[u] += sz[it];
    int t1 = work(k[it], u);
    int t2 = work(k[u], u);
    if (deep[t1] >= deep[t2])
      k[u] = t1;
    else
      k[u] = t2;
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    g[i].push_back(x);
    g[x].push_back(i);
  }
  deep[1] = 0;
  dfs(1, 0);
  for (int i = 1; i <= q; i++) {
    int x;
    scanf("%d", &x);
    printf("%d\n", k[x]);
  }
  return 0;
}
