#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, qu;
  cin >> n >> qu;
  vector<int> adj[n];
  int par[n];
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    p--;
    par[i] = p;
    adj[p].push_back(i);
    adj[i].push_back(p);
  }
  int l[n];
  int cen[n];
  int pl[n];
  bool used[n];
  for (int i = 0; i < n; i++) {
    l[i] = 0;
    used[i] = 0;
    pl[i] = 1;
    cen[i] = -1;
  }
  queue<int> q;
  q.push(0);
  l[0] = 0;
  used[0] = true;
  vector<int> v;
  while (!q.empty()) {
    int fr = q.front();
    q.pop();
    v.push_back(fr);
    for (int i = 0; i < adj[fr].size(); i++) {
      int next = adj[fr][i];
      if (!used[next]) {
        used[next] = true;
        q.push(next);
        l[next] = l[fr] + 1;
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < adj[v[i]].size(); j++) {
      if (l[v[i]] < l[adj[v[i]][j]]) {
        pl[v[i]] += pl[adj[v[i]][j]];
      }
    }
    if (pl[v[i]] == 1) {
      cen[v[i]] = v[i];
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (cen[v[i]] == -1) {
      int maxfound = 0;
      int ind = v[i];
      for (int j = 0; j < adj[v[i]].size(); j++) {
        if (l[v[i]] < l[adj[v[i]][j]]) {
          if (maxfound < pl[adj[v[i]][j]]) {
            maxfound = pl[adj[v[i]][j]];
            ind = adj[v[i]][j];
          }
        }
      }
      int pos = cen[ind];
      while (pos != v[i] and (pl[v[i]] - pl[pos]) * 2 > pl[v[i]]) {
        pos = par[pos];
      }
      cen[v[i]] = pos;
    }
  }
  ostringstream ostr;
  for (int i = 0; i < qu; i++) {
    int val;
    cin >> val;
    val--;
    ostr << cen[val] + 1 << '\n';
  }
  cout << ostr.str();
}
