#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, z, k, w;
int LINK[600005], ed[600005], l[300005];
int T[300005], ANS[300005], Q[300005], P[300005], ans[300005], q;
void bd(int x, int y) {
  LINK[w] = l[x];
  l[x] = w;
  ed[w] = y;
  w++;
}
void DFS(int x, int y) {
  for (int i = l[x]; i != -1; i = LINK[i]) {
    if (ed[i] == y) continue;
    DFS(ed[i], x);
    T[x] += T[ed[i]];
    P[x] = max(T[ed[i]], P[x]);
  }
  T[x]++;
}
bool check(int a, int x) {
  int p = T[a] - T[x];
  p = max(p, P[x]);
  if (p * 2 > T[a]) return 0;
  ans[a] = x;
  return 1;
}
void dfs(int x, int y) {
  Q[w++] = x;
  while (k < w) {
    if (check(Q[k], x) == 1)
      k++;
    else
      break;
  }
  int h = 0, pos = 0;
  for (int i = l[x]; i != -1; i = LINK[i]) {
    if (ed[i] == y) continue;
    if (T[ed[i]] > h) {
      h = T[ed[i]];
      pos = ed[i];
    }
  }
  if (pos != 0) dfs(pos, x);
  for (int i = l[x]; i != -1; i = LINK[i]) {
    if (ed[i] == y || ed[i] == pos) continue;
    dfs(ed[i], x);
  }
}
int main() {
  scanf("%d %d", &n, &q);
  memset(l, -1, sizeof(l));
  for (int i = (2); i <= (n); i++) {
    scanf("%d", &x);
    bd(x, i);
    bd(i, x);
  }
  w = 0;
  k = 0;
  DFS(1, 0);
  dfs(1, 0);
  for (int i = (0); i < (q); i++) {
    scanf("%d", &x);
    printf("%d\n", ans[x]);
  }
  return 0;
}
