#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
vector<int> centroid(300010), subsize(300010), parent(300010);
vector<int> graph[300010], refer(300010);
set<pair<int, int> > s[300010];
void dfs(int u) {
  int maxi = -1, child = -1;
  subsize[u] = 1;
  for (int i = 0; i < (int)(graph[u].size()); i++) {
    int v = graph[u][i];
    if (v != parent[u]) {
      dfs(v);
      subsize[u] += subsize[v];
      if (subsize[v] >= maxi) {
        maxi = subsize[v];
        child = v;
      }
    }
  }
  if (maxi == -1) {
    centroid[u] = u;
    s[u].insert(make_pair(1, u));
    refer[u] = u;
  } else {
    refer[u] = refer[child];
    s[refer[u]].insert(make_pair(subsize[u], u));
    set<pair<int, int> >::iterator it, it1;
    for (int i = 0; i < (int)(graph[u].size()); i++) {
      int v = graph[u][i];
      if (v != parent[u] && v != child) {
        for (it = s[refer[v]].begin(); it != s[refer[v]].end(); it++)
          s[refer[u]].insert(*it);
      }
    }
    it1 = s[refer[u]].lower_bound(make_pair((subsize[u] + 1) / 2, 0));
    centroid[u] = (*it1).second;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  for (int i = 2; i < n + 1; i++) {
    int a;
    cin >> a;
    parent[i] = a;
    graph[a].push_back(i);
    graph[i].push_back(a);
  }
  dfs(1);
  for (int i = 0; i < q; i++) {
    int v;
    cin >> v;
    cout << centroid[v] << "\n";
  }
  return 0;
}
