#include <bits/stdc++.h>
using namespace std;
vector<int> g[300100];
int sz[300100], ans[300100];
int fa[300100];
int n, q;
void dfs(int v, int p) {
  sz[v] = 1;
  fa[v] = p;
  int mxid = 0;
  for (int i = 0; i < g[v].size(); i++) {
    int u = g[v][i];
    if (u == p) continue;
    dfs(u, v);
    sz[v] += sz[u];
    if (sz[u] > sz[mxid]) mxid = u;
  }
  if (sz[v] == 1)
    ans[v] = v;
  else {
    ans[v] = ans[mxid];
    while (ans[v] != v && 2 * sz[ans[v]] < sz[v]) ans[v] = fa[ans[v]];
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    g[i].push_back(x);
    g[x].push_back(i);
  }
  dfs(1, 0);
  while (q--) {
    int x;
    scanf("%d", &x);
    printf("%d\n", ans[x]);
  }
  return 0;
}
