#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\t';
  err(++it, args...);
}
const int mod = 1e9 + 7;
const long long int inf = 2e18;
const long double eps = 1e-9;
const int NN = 3e5 + 2;
vector<long long int> adj[NN];
int ar[NN], sz[NN], pp[NN], maxchild[NN];
bool vis[NN];
void pre_dfs(int x, int par) {
  sz[x] = 1;
  pp[x] = par;
  for (auto it : adj[x]) {
    if (it == par) continue;
    pre_dfs(it, x);
    sz[x] += sz[it];
    if (sz[it] > sz[maxchild[x]]) {
      maxchild[x] = it;
    }
  }
}
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  stack<int> st;
  st.push(x);
  int i = x, j = x;
  while (1) {
    if (sz[maxchild[j]] <= sz[i] / 2) {
      ar[i] = j;
      if (i == j) break;
      i = maxchild[i];
    } else {
      j = maxchild[j];
      st.push(j);
    }
  }
  while (!st.empty()) {
    i = st.top();
    vis[i] = 1;
    for (int c : adj[i]) {
      if (c != pp[i]) dfs(c);
    }
    st.pop();
  }
}
void solve() {
  int i = 0, j = 0, k = 0, n = 0, m = 0;
  cin >> n >> m;
  for (i = 2; i < (n + 1); i++) {
    cin >> k;
    adj[i].push_back(k);
    adj[k].push_back(i);
  }
  pre_dfs(1, 0);
  dfs(1);
  while (m--) {
    cin >> k;
    cout << ar[k];
    cout << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T = 1, tc;
  for (tc = 1; tc < (T + 1); tc++) {
    solve();
  }
  return 0;
}
