#include <bits/stdc++.h>
using namespace std;
int getint(void) {
  int i;
  scanf("%d", &i);
  return i;
}
const int maxn = 3e5;
int n, q;
vector<int> G[maxn];
int father[maxn];
int weight[maxn];
int heavy_son[maxn];
int heavy_weight[maxn];
int centroid[maxn];
void dfs(int u, int fa) {
  father[u] = fa;
  weight[u] = 1;
  heavy_son[u] = -1;
  heavy_weight[u] = 0;
  for (int i = 0; i < (int)G[u].size(); ++i) {
    int v = G[u][i];
    dfs(v, u);
    weight[u] += weight[v];
    if (weight[v] > heavy_weight[u]) {
      heavy_son[u] = v;
      heavy_weight[u] = weight[v];
    }
  }
  if (heavy_son[u] == -1)
    centroid[u] = u;
  else {
    int v = centroid[heavy_son[u]];
    while (2 * (weight[u] - weight[v]) >= weight[u]) v = father[v];
    centroid[u] = v;
  }
}
int ans[maxn];
void solve(void) {
  dfs(0, -1);
  for (int i = 0; i < n; ++i) ans[i] = centroid[i] + 1;
}
int main(void) {
  n = getint(), q = getint();
  for (int i = 1; i < n; ++i) G[getint() - 1].push_back(i);
  solve();
  for (int i = 0; i < q; ++i) printf("%d\n", ans[getint() - 1]);
  return 0;
}
