#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const double PI = 2 * acos(0.0);
inline int cmp(double x, double y = 0, double tol = EPS) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
bool debug = false;
vector<int> grafo[312345];
int pai[312345];
int cont[312345];
int centroid[312345];
void dfs(int u) {
  cont[u] = 1;
  if (int(grafo[u].size()) == 0) {
    centroid[u] = u;
    return;
  }
  int auxId = grafo[u][0];
  for (int i = 0; i < int(grafo[u].size()); ++i) {
    int v = grafo[u][i];
    dfs(v);
    if (cont[v] > cont[auxId]) auxId = v;
    cont[u] += cont[v];
  }
  if (cont[auxId] <= cont[u] / 2) {
    centroid[u] = u;
    return;
  }
  centroid[u] = centroid[auxId];
  while (cont[u] - cont[centroid[u]] > cont[u] / 2) {
    centroid[u] = pai[centroid[u]];
  }
}
int main(void) {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; ++i) {
    scanf("%d", &pai[i]);
    grafo[pai[i]].push_back(i);
  }
  dfs(1);
  for (int i = 0, u; i < q; ++i) {
    scanf("%d", &u);
    printf("%d\n", centroid[u]);
  }
  return 0;
}
