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