#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 7;
vector<int> E[maxn];
int n, q, sz[maxn], ans[maxn], f[maxn];
void dfs(int x) {
  ans[x] = x;
  sz[x] = 1;
  for (int i = 0; i < E[x].size(); i++) {
    int v = E[x][i];
    dfs(v);
    sz[x] += sz[v];
  }
  for (int i = 0; i < E[x].size(); i++) {
    if (sz[E[x][i]] * 2 > sz[x]) ans[x] = ans[E[x][i]];
  }
  while ((sz[x] - sz[ans[x]]) * 2 > sz[x]) ans[x] = f[ans[x]];
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &f[i]);
    E[f[i]].push_back(i);
  }
  dfs(1);
  for (int i = 1; i <= q; i++) {
    int x;
    scanf("%d", &x);
    printf("%d\n", ans[x]);
  }
}
