#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
vector<int> gr[N];
int qtd[N], centroid[N], pai[N];
int up(int u, int tam) {
  int sz = tam - qtd[u];
  if (sz * 2 <= tam) return u;
  return up(pai[u], tam);
}
int dfs(int u) {
  qtd[u] = 1;
  for (auto v : gr[u]) {
    qtd[u] += dfs(v);
  }
  int sz = 0;
  for (auto v : gr[u]) {
    sz = max(sz, qtd[v]);
  }
  if (sz * 2 <= qtd[u]) {
    centroid[u] = u;
    return qtd[u];
  }
  for (auto v : gr[u]) {
    if (sz == qtd[v]) centroid[u] = up(centroid[v], qtd[u]);
  }
  return qtd[u];
}
int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 2; i <= n; i++) {
    int y;
    scanf("%d", &y);
    pai[i] = y;
    gr[y].push_back(i);
  }
  dfs(1);
  for (int i = 0; i < m; i++) {
    int u;
    scanf("%d", &u);
    printf("%d\n", centroid[u]);
  }
  return 0;
}
