#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
vector<int> G[maxn];
int siz[maxn], son[maxn], fa[maxn], ans[maxn];
int n, q;
void dfs(int u, int f) {
  siz[u] = 1, son[u] = 0;
  for (auto &v : G[u]) {
    if (v == f) continue;
    dfs(v, u);
    siz[u] += siz[v];
    if (siz[v] > siz[son[u]]) son[u] = v;
  }
  if (siz[son[u]] * 2 <= siz[u])
    ans[u] = u;
  else {
    int v = ans[son[u]];
    while ((siz[u] - siz[v]) * 2 > siz[u]) v = fa[v];
    ans[u] = v;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    int u;
    cin >> u;
    G[u].push_back(i), G[i].push_back(u);
    fa[i] = u;
  }
  dfs(1, 0);
  while (q--) {
    int x;
    cin >> x;
    cout << ans[x] << "\n";
  }
  return 0;
}
