#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\t';
  err(++it, args...);
}
const long double eps = 1e-9;
const long long mod = 1e9 + 7;
pair<long long, long long> dir[8] = {{-1, 0}, {1, 0},   {0, -1}, {0, 1},
                                     {1, 1},  {-1, -1}, {-1, 1}, {1, -1}};
const long long nn = 3e5 + 5;
vector<long long> g[nn];
long long par[nn];
long long sz[nn];
long long centroid[nn];
void dfs(long long v) {
  sz[v] = 1;
  for (long long to : g[v]) {
    dfs(to);
    sz[v] += sz[to];
  }
  long long bad = -1;
  for (long long to : g[v]) {
    if (sz[to] * 2 > sz[v]) bad = to;
  }
  if (bad == -1) {
    centroid[v] = v;
  } else {
    centroid[v] = centroid[bad];
    while (sz[centroid[v]] * 2 <= sz[v]) {
      centroid[v] = par[centroid[v]];
    }
  }
}
void robin() {
  long long n, q;
  cin >> n >> q;
  for (long long i = 2; i <= n; i++) {
    long long v;
    cin >> v;
    par[i] = v;
    g[v].push_back(i);
  }
  dfs(1);
  while (q--) {
    long long v;
    cin >> v;
    cout << centroid[v] << '\n';
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  for (long long tc = 1; tc <= T; tc++) {
    robin();
  }
  return 0;
}
