#include <bits/stdc++.h>
using namespace std;
int dfs(int v, vector<int> &sizes, vector<int> &centroids,
        const vector<vector<int> > &g, const vector<int> &parent) {
  pair<int, int> max_child{-1, -1};
  sizes[v] = 1;
  for (int to : g[v]) {
    sizes[v] += dfs(to, sizes, centroids, g, parent);
    max_child = max(max_child, make_pair(sizes[to], to));
  }
  if (g[v].empty()) {
    centroids[v] = v;
  } else {
    int centroid = -1;
    for (int cur = centroids[max_child.second]; cur != -1; cur = parent[cur]) {
      if (sizes[cur] * 2 >= sizes[v]) {
        centroid = cur;
        break;
      }
    }
    centroids[v] = centroid;
  }
  return sizes[v];
}
void solve(int n) {
  int q;
  scanf("%d", &q);
  vector<int> parent(n, -1);
  vector<vector<int> > g(n);
  for (int i = 1; i < n; ++i) {
    int p;
    scanf("%d", &p);
    --p;
    parent[i] = p;
    g[p].push_back(i);
  }
  vector<int> sizes(n, 0), centroids(n, -1);
  dfs(0, sizes, centroids, g, parent);
  for (int i = 0; i < q; ++i) {
    int v;
    scanf("%d", &v);
    --v;
    printf("%d\n", centroids[v] + 1);
  }
}
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    solve(n);
  }
  return 0;
}
