#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int n, m, fa[maxn], rt[maxn], sz[maxn], mx[maxn];
vector<int> G[maxn];
void dfs(int u, int pre) {
  sz[u] = 1;
  for (int v : G[u]) {
    dfs(v, u);
    sz[u] += sz[v];
    mx[u] = max(mx[u], sz[v]);
  }
  int id = u, me = mx[u];
  for (int v : G[u]) {
    int it = rt[v], pre = max(mx[it], sz[u] - sz[it]), p = it;
    while (fa[it] != u) {
      it = fa[it];
      int New = max(mx[it], sz[u] - sz[it]);
      if (New < pre) {
        pre = New;
        p = it;
      } else
        break;
    }
    if (me > pre) {
      me = pre;
      id = p;
    }
  }
  rt[u] = id;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &fa[i]);
    G[fa[i]].push_back(i);
  }
  dfs(1, 0);
  while (m--) {
    int x;
    scanf("%d", &x);
    printf("%d\n", rt[x]);
  }
  return 0;
}
