#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], mx[maxn], fa[maxn][21], pre[maxn], ans[maxn];
int n, q;
void dfs1(int u, int f) {
  mx[u] = 0, siz[u] = 1, pre[u] = f;
  for (auto &v : G[u]) {
    if (v == f) continue;
    fa[v][0] = u;
    for (int i = 1; i <= 20; ++i) fa[v][i] = fa[fa[v][i - 1]][i - 1];
    dfs1(v, u);
    siz[u] += siz[v];
    mx[u] = max(mx[u], siz[v]);
  }
}
int jump(int u) {
  int l = 2 * mx[u];
  if (siz[u] >= l) return u;
  for (int i = 20; i >= 0; --i) {
    if (fa[u][i] && siz[fa[u][i]] < l) u = fa[u][i];
  }
  return fa[u][0];
}
void dfs2(int u, int f) {
  for (auto &v : G[u]) {
    if (v == f) continue;
    dfs2(v, u);
  }
  int v = jump(u), r = 2 * siz[u], p;
  for (p = v; p && siz[p] <= r; p = pre[p]) {
    ans[p] = u;
  }
  while (v && siz[v] <= r) {
    int t = pre[v];
    pre[v] = p;
    v = t;
  }
}
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);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  while (q--) {
    int x;
    cin >> x;
    cout << ans[x] << "\n";
  }
  return 0;
}
