#include <bits/stdc++.h>
using namespace std;
const int mxn = 300000 + 10;
vector<int> g[mxn];
int fa[mxn];
int son[mxn];
int ans[mxn];
void dfs(int u) {
  son[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    dfs(v);
    son[u] += son[v];
  }
  ans[u] = u;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (2 * son[v] >= son[u]) ans[u] = ans[v];
  }
  while (2 * son[ans[u]] < son[u]) ans[u] = fa[ans[u]];
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int f;
    scanf("%d", &f);
    g[f].push_back(i);
    fa[i] = f;
  }
  dfs(1);
  while (q--) {
    int qq;
    scanf("%d", &qq);
    printf("%d\n", ans[qq]);
  }
  return 0;
}
