#include <bits/stdc++.h>
using namespace std;
int n, k, a;
vector<vector<int> > G;
vector<int> w, ans, p, max_ch, max_ch_sz;
void dfs1(int a) {
  int mx = 0, num = 0;
  if ((int)G[a].size() != 0)
    for (int i = 0; i < (int)G[a].size(); i++) {
      int to = G[a][i];
      dfs1(to);
      w[a] += w[to];
      if (mx < w[to]) {
        mx = w[to];
        num = to;
      }
    }
  w[a]++;
  max_ch[a] = num;
  max_ch_sz[a] = mx;
}
void dfs2(int a) {
  if (w[a] == 1)
    ans[a] = a;
  else {
    for (int i = 0; i < (int)G[a].size(); i++) {
      int to = G[a][i];
      dfs2(to);
    }
    int to = ans[max_ch[a]];
    bool ok = 0;
    while (!ok) {
      int mxc = 0;
      mxc = max(mxc, max_ch_sz[to]);
      mxc = max(mxc, w[a] - w[to]);
      if (mxc <= w[a] / 2)
        ok = 1;
      else
        to = p[to];
    }
    ans[a] = to;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  G.resize(n + 1);
  w.resize(n + 1, 0);
  ans.resize(n + 1);
  p.resize(n + 1);
  max_ch.resize(n + 1);
  max_ch_sz.resize(n + 1, 0);
  for (int i = 2; i <= n; i++) {
    cin >> a;
    G[a].push_back(i);
    p[i] = a;
  }
  dfs1(1);
  dfs2(1);
  for (int i = 0; i < k; i++) {
    cin >> a;
    cout << ans[a] << endl;
  }
}
