#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e5 + 9;
int sz[MAX], ans[MAX], p[MAX], n, q;
vector<int> g[MAX];
int dfs(int v) {
  sz[v] = 1;
  for (auto u : g[v]) sz[v] += dfs(u);
  return sz[v];
}
void calc(int v) {
  int bes = -1;
  for (auto u : g[v]) {
    calc(u);
    if (sz[u] >= ceil(sz[v] / 2.0)) bes = u;
  }
  if (bes == -1) {
    ans[v] = v;
    return;
  }
  int t = ans[bes];
  while (sz[t] < ceil(sz[v] / 2.0)) t = p[t];
  ans[v] = t;
}
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], p[i]--, g[p[i]].push_back(i);
  dfs(0), calc(0);
  while (q--) {
    int x;
    cin >> x, x--;
    cout << ans[x] + 1 << '\n';
  }
  return 0;
}
