#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e9;
long long powm(long long a, long long p, long long m) {
  long long r = 1 % m;
  while (p) {
    if (p & 1) r = r * a % m;
    p >>= 1;
    a = a * a % m;
  }
  return r;
}
int n, q;
vector<int> lst[300001];
int ans[300001];
set<pair<int, int> > s[300001];
int dfs(int p) {
  int cnt = 1;
  for (int i = 0; i < lst[p].size(); ++i) {
    cnt += dfs(lst[p][i]);
    if (s[p].size() < s[lst[p][i]].size()) swap(s[p], s[lst[p][i]]);
    s[p].insert(s[lst[p][i]].begin(), s[lst[p][i]].end());
  }
  s[p].insert(make_pair(cnt, p));
  ans[p] = s[p].lower_bound(make_pair((cnt + 1) / 2, 0))->second;
  return cnt;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2, p; i <= n; ++i) {
    scanf("%d", &p);
    lst[p].push_back(i);
  }
  dfs(1);
  for (int i = 0, v; i < q; ++i) {
    scanf("%d", &v);
    printf("%d\n", ans[v]);
  }
  return 0;
}
