#include <bits/stdc++.h>
using namespace std;
const int maxm = 3e5 + 5;
vector<int> g[maxm];
int fa[maxm];
int sz[maxm], son[maxm];
int ans[maxm];
int n, q;
void dfs(int x) {
  sz[x] = 1;
  son[x] = 0;
  ans[x] = x;
  int len = g[x].size();
  int root = x;
  for (int i = 0; i < len; i++) {
    int v = g[x][i];
    dfs(v);
    sz[x] += sz[v];
    if (sz[v] > son[x]) {
      son[x] = sz[v];
      root = v;
    }
  }
  ans[x] = ans[root];
  while (ans[x] != x && sz[x] > sz[ans[x]] * 2) {
    ans[x] = fa[ans[x]];
  }
}
signed main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &fa[i]);
    g[fa[i]].push_back(i);
  }
  dfs(1);
  while (q--) {
    int x;
    scanf("%d", &x);
    printf("%d\n", ans[x]);
  }
  return 0;
}
