#include <bits/stdc++.h>
using namespace std;
const int max_n = 300010;
vector<int> g[max_n];
int p[max_n], s[max_n], centroid[max_n];
int find_centroids(int u) {
  centroid[u] = u;
  s[u] = 1;
  int max_s = 0;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    s[u] += find_centroids(v);
    if (s[v] > s[max_s]) max_s = v;
  }
  if (s[max_s] * 2 > s[u]) {
    int c = centroid[max_s];
    while (2 * (s[u] - s[c]) > s[u]) c = p[c];
    centroid[u] = c;
  }
  return s[u];
}
int main() {
  int n, q, v;
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    cin >> p[i];
    g[p[i]].push_back(i);
  }
  find_centroids(1);
  while (q--) {
    cin >> v;
    cout << centroid[v] << endl;
  }
  return 0;
}
