#include <bits/stdc++.h>
using namespace std;
int vis[300005], par[300005], cn[300005], cent[300005];
map<int, int> m1, m2;
vector<int> aj[300005];
vector<pair<int, int> > adj[300005];
int dfs(int i) {
  int r = 1, t;
  for (auto it : aj[i]) r += dfs(it);
  adj[par[i]].push_back(make_pair(r, i));
  sort(adj[i].begin(), adj[i].end());
  aj[i].clear();
  for (__typeof(adj[i].begin()) it = adj[i].end(); it-- != adj[i].begin();)
    aj[i].push_back((*it).second);
  return r;
}
int dfs(int i, map<int, int> &m1) {
  vis[i] = 1;
  int r = 1, mx = 0, t;
  if (aj[i].size() == 0) {
    m1[1] = i;
    cn[i] = 1;
    cent[i] = i;
    return 1;
  }
  if (aj[i].size() == 1) {
    mx = dfs(aj[i][0], m1);
    r += mx;
    cn[i] = r;
    if (m1.find(r) == m1.end() || cn[i] > cn[m1[r]]) m1[r] = i;
    cent[i] = (*(m1.lower_bound((r + 1) / 2))).second;
    return r;
  }
  map<int, int> m3;
  for (auto it : aj[i]) {
    m3.clear();
    if (it == aj[i][0])
      t = dfs(it, m1);
    else
      t = dfs(it, m3);
    r += t;
    mx = max(t, mx);
  }
  m1[r] = i;
  cent[i] = (*(m1.lower_bound((r + 1) / 2))).second;
  cn[i] = r;
  return r;
}
int main() {
  int n, q, a;
  cin >> n >> q;
  for (int i = 2; i < n + 1; i++) {
    scanf("%d", &par[i]);
    aj[par[i]].push_back(i);
  }
  dfs(1);
  dfs(1, m1);
  for (int i = 0; i < q; i++) {
    scanf("%d", &a);
    printf("%d\n", cent[a]);
  }
}
