#include <bits/stdc++.h>
using namespace std;
int N, Q;
int par[300003];
int ans[300003];
int siz[300003];
vector<int> child[300003];
int root;
int dfs_siz(int a) {
  int ret = 0;
  for (int i = 0; i < child[a].size(); i++) {
    ret += dfs_siz(child[a][i]);
  }
  siz[a] = ret + 1;
  return siz[a];
}
void dfs_ans(int a) {
  if (child[a].size() == 0) {
    ans[a] = a;
  }
  int heavyval = -1;
  for (int i = 0; i < child[a].size(); i++) {
    dfs_ans(child[a][i]);
    if (siz[child[a][i]] * 2 >= siz[a]) {
      heavyval = child[a][i];
    }
  }
  if (heavyval == -1) {
    ans[a] = a;
  } else {
    ans[a] = ans[heavyval];
    while (2 * siz[ans[a]] < siz[a]) {
      ans[a] = par[ans[a]];
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  if (fopen("cf686d.in", "r")) {
    freopen("cf686d.in", "r", stdin);
    freopen("cf686d.out", "w", stdout);
  }
  cin >> N >> Q;
  root = 0;
  for (int i = 1; i < N; i++) {
    cin >> par[i];
    par[i]--;
    child[par[i]].push_back(i);
  }
  dfs_siz(root);
  dfs_ans(root);
  for (int i = 0; i < Q; i++) {
    int x;
    cin >> x;
    x--;
    cout << ans[x] + 1 << '\n';
  }
  return 0;
}
