#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
vector<int> adj[300005];
int child[300005];
int centroids[300005];
int par[300005];
int max_subtree_size[300005];
int dfs(int node) {
  child[node] = 1;
  max_subtree_size[node] = 0;
  for (auto it : adj[node]) {
    child[node] += dfs(it);
    max_subtree_size[node] = max(max_subtree_size[node], child[it]);
  }
  return child[node];
}
bool check_if_centroid(int u, int c) {
  return (child[u] - child[c]) * 2 <= child[u];
}
int centroid(int node) {
  if (child[node] == 1)
    centroids[node] = node;
  else {
    int max_subtree = -1;
    int max_pos = node;
    for (auto it : adj[node]) {
      centroid(it);
      if (child[it] > max_subtree) {
        max_subtree = child[it];
        max_pos = it;
      }
    }
    int curr_centroid = centroids[max_pos];
    while (!check_if_centroid(node, curr_centroid)) {
      curr_centroid = par[curr_centroid];
    }
    centroids[node] = curr_centroid;
  }
  return centroids[node];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = int(2); i <= int(n); i++) {
    int parent;
    cin >> parent;
    adj[parent].push_back(i);
    par[i] = parent;
  }
  par[1] = 1;
  dfs(1);
  centroid(1);
  while (q--) {
    int node;
    cin >> node;
    cout << centroids[node] << ('\n');
  }
  return 0;
}
