#include <bits/stdc++.h>
using namespace std;
int sz[300004];
int ans[300004];
vector<vector<int>> v;
set<int> s;
int dfsz(int x) {
  for (int y : v[x]) {
    sz[x] += dfsz(y);
  }
  sz[x]++;
  return sz[x];
}
set<pair<int, int>> dfs(int x) {
  pair<int, int> largest(-1, -1);
  for (int y : v[x]) {
    largest = max(largest, make_pair(sz[y], y));
  }
  set<pair<int, int>> res;
  if (largest.second != -1) {
    res = dfs(largest.second);
    for (int y : v[x]) {
      if (y == largest.second) continue;
      auto temp = dfs(y);
      res.insert(temp.begin(), temp.end());
    }
  }
  res.insert(make_pair(sz[x], x));
  ans[x] = res.upper_bound(make_pair(sz[x] / 2, 1e9))->second;
  return res;
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  v.resize(n);
  for (int i = 1; i < n; i++) {
    int x;
    scanf("%d", &x);
    x--;
    v[x].push_back(i);
  }
  dfsz(0);
  dfs(0);
  while (q--) {
    int x;
    scanf("%d", &x);
    printf("%d\n", ans[x - 1] + 1);
  }
  return 0;
}
