#include <bits/stdc++.h>
using namespace std;
vector<int> g[300100];
int sum[300100], mxson[300100], n, ans[300100];
int fa[300100];
void dfs(int pre, int u) {
  int v, tmp;
  sum[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    v = g[u][i];
    if (v == pre) continue;
    dfs(u, v);
    sum[u] += sum[v];
    fa[v] = u;
    mxson[u] = max(mxson[u], sum[v]);
  }
}
bool check(int u, int v) {
  if (mxson[v] * 2 <= sum[u] && 2 * (sum[u] - sum[v]) <= sum[u]) return true;
  return false;
}
void dfs2(int pre, int u) {
  int v, tmp;
  if (sum[u] == 1) {
    ans[u] = u;
    return;
  }
  for (int i = 0; i < g[u].size(); i++) {
    v = g[u][i];
    if (v == pre) continue;
    dfs2(u, v);
    if (sum[v] == mxson[u]) {
      tmp = ans[v];
    }
  }
  while (!check(u, tmp)) {
    tmp = fa[tmp];
  }
  ans[u] = tmp;
}
int main() {
  int a, b, c, cas;
  scanf("%d", &n);
  scanf("%d", &cas);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &a);
    g[a].push_back(i);
    g[i].push_back(a);
  }
  dfs(0, 1);
  dfs2(0, 1);
  while (cas--) {
    scanf("%d", &a);
    printf("%d\n", ans[a]);
  }
  return 0;
}
