#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e5 + 11;
int n, q;
int parent[MAX];
int size_of[MAX];
int centroid[MAX];
vector<int> graf[MAX];
bool is_valid(int v, int c) {
  return ((size_of[v] - size_of[c]) * 2 <= size_of[v]);
}
int dfs_calc(int v, int p) {
  size_of[v] = 1;
  parent[v] = p;
  for (int i = 0; i < graf[v].size(); ++i)
    size_of[v] += dfs_calc(graf[v][i], v);
  return size_of[v];
}
void dfs_centroid(int v) {
  if (size_of[v] == 1) {
    centroid[v] = v;
    return;
  }
  int p = 0;
  for (int i = 0; i < graf[v].size(); ++i) {
    dfs_centroid(graf[v][i]);
    if (size_of[graf[v][p]] < size_of[graf[v][i]]) p = i;
  }
  int c = centroid[graf[v][p]];
  while (!is_valid(v, c)) c = parent[c];
  centroid[v] = c;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  int v;
  for (int i = 1; i < n; ++i) {
    cin >> v;
    graf[--v].push_back(i);
  }
  dfs_calc(0, 0);
  dfs_centroid(0);
  for (int i = 0; i < q; ++i) {
    cin >> v;
    cout << centroid[--v] + 1 << endl;
  }
  return 0;
}
