#include <bits/stdc++.h>
using namespace std;
const int MAX = 300003;
int n, q, p;
vector<int> g[MAX];
int cnt[MAX], centroid[MAX], parent[MAX];
int dfs1(int u) {
  int c = 1;
  for (int i = 0; i < g[u].size(); i++) c += dfs1(g[u][i]);
  cnt[u] = c;
  return c;
}
bool iscentroid(int u, int y) {
  if (cnt[u] % 2 == 0 && cnt[y] >= cnt[u] / 2)
    return true;
  else if (cnt[u] % 2 == 1 && cnt[y] >= cnt[u] / 2 + 1)
    return true;
  return false;
}
int dfs2(int u) {
  int x = u;
  for (int i = 0; i < g[u].size(); i++) {
    int y = dfs2(g[u][i]);
    while (!iscentroid(u, y)) y = parent[y];
    if (cnt[x] > cnt[y]) x = y;
  }
  centroid[u] = x;
  return x;
}
int main() {
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    cin >> p;
    g[p].push_back(i);
    parent[i] = p;
  }
  dfs1(1);
  for (int i = 1; i <= n; i++) centroid[i] = i;
  dfs2(1);
  for (int i = 1; i <= q; i++) {
    cin >> p;
    cout << centroid[p] << endl;
  }
  return 0;
}
