#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, m;
vector<int> G[N];
int fa[N];
int ans[N], mx[N], siz[N], sum;
void dfs(int u) {
  siz[u] = 1;
  mx[u] = 0;
  ans[u] = u;
  int rt = 0;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    dfs(v);
    siz[u] += siz[v];
    if (siz[rt] < siz[v]) rt = v;
  }
  if (siz[rt] * 2 > siz[u]) {
    int t = ans[rt];
    while ((siz[u] - siz[t]) * 2 > siz[u]) t = fa[t];
    ans[u] = t;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= n; i++) {
    int p;
    scanf("%d", &p);
    G[p].push_back(i);
    fa[i] = p;
  }
  dfs(1);
  while (m--) {
    int q;
    scanf("%d", &q);
    printf("%d\n", ans[q]);
  }
  return 0;
}
