#include <bits/stdc++.h>
inline int Rand() { return (rand() << 16) | rand(); }
using namespace std;
const int BIG = 300001;
int n, q, x, ans[BIG], sz[BIG];
vector<int> g[BIG];
set<pair<int, int> > dfs(int v) {
  sz[v] = 1;
  set<pair<int, int> > st;
  for (int i = int(0); i <= int(g[v].size() - 1); i++) {
    set<pair<int, int> > cmp = dfs(g[v][i]);
    sz[v] += sz[g[v][i]];
    if (st.size() < cmp.size()) swap(st, cmp);
    for (set<pair<int, int> >::iterator it = cmp.begin(); it != cmp.end(); it++)
      st.insert(*it);
  }
  st.insert(make_pair(sz[v], v));
  ans[v] = st.lower_bound(make_pair((sz[v] + 1) / 2, -2000000000))->second;
  return st;
}
int main() {
  srand(time(NULL));
  scanf("%d %d", &n, &q);
  for (int i = int(2); i <= int(n); i++) scanf("%d", &x), g[x].push_back(i);
  dfs(1);
  for (int i = int(1); i <= int(q); i++)
    scanf("%d", &x), printf("%d\n", ans[x]);
  return 0;
}
