#include <bits/stdc++.h>
using namespace std;
const int N = 300100;
int ans[N];
int parent[N];
int subtree_size[N];
vector<int> adj[N];
void dfs(int src) {
  subtree_size[src] = 1;
  for (int i = 0; i < adj[src].size(); i++) {
    int child = adj[src][i];
    dfs(child);
    subtree_size[src] += subtree_size[child];
  }
  return;
}
void get_centroid(int src) {
  bool is_centroid = true;
  int heaviest_child = -1;
  int node_count = subtree_size[src];
  ans[src] = src;
  for (int i = 0; i < adj[src].size(); i++) {
    int child = adj[src][i];
    get_centroid(child);
    if (subtree_size[child] > (node_count / 2)) is_centroid = false;
    if (heaviest_child == -1 ||
        subtree_size[child] > subtree_size[heaviest_child])
      heaviest_child = child;
  }
  if (!is_centroid) {
    int cent = ans[heaviest_child];
    while (subtree_size[cent] <= (node_count / 2)) {
      cent = parent[cent];
    }
    ans[src] = cent;
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  parent[1] = 1;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    parent[i] = x;
    adj[x].push_back(i);
  }
  dfs(1);
  get_centroid(1);
  while (q--) {
    int x;
    cin >> x;
    cout << ans[x] << endl;
  }
  return 0;
}
