#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 100;
int n, q, sz[N], p[N], res[N];
vector<int> e[N];
void dfs(int v) {
  sz[v] = 1;
  int bc = -1;
  for (auto u : e[v]) {
    dfs(u);
    sz[v] += sz[u];
    if (bc == -1 || sz[u] > sz[bc]) bc = u;
  }
  if (bc == -1 || sz[bc] <= sz[v] / 2) {
    res[v] = v;
    return;
  }
  int cn = res[bc];
  while (true) {
    if (sz[v] - sz[cn] <= sz[v] / 2) break;
    cn = p[cn];
  }
  res[v] = cn;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    cin >> p[i];
    e[--p[i]].push_back(i);
  }
  dfs(0);
  while (q--) {
    int v;
    cin >> v;
    cout << res[--v] + 1 << '\n';
  }
  return 0;
}
