#include <bits/stdc++.h>
using namespace std;
const int Max = 3e5 + 10;
const int E = Max * 2;
int son[Max], maxson[Max], fa[Max], zx[Max];
int head[Max], nex[E], pnt[E], edge;
int vis[Max];
void Init() {
  edge = 0;
  memset(son, 0, sizeof(son));
  memset(maxson, 0, sizeof(maxson));
  memset(fa, -1, sizeof(fa));
  memset(head, -1, sizeof(head));
  memset(vis, 0, sizeof(vis));
}
void Addedge(int u, int v) {
  pnt[edge] = v;
  nex[edge] = head[u];
  head[u] = edge++;
}
void dfs1(int u) {
  son[u] = 1;
  vis[u] = 1;
  maxson[u] = 0;
  int v;
  for (int e = head[u]; e != -1; e = nex[e]) {
    v = pnt[e];
    if (!vis[v]) {
      dfs1(v);
      son[u] += son[v];
      maxson[u] = max(maxson[u], son[v]);
    }
  }
}
bool is_ok(int u, int v) {
  if (son[u] >= maxson[v] * 2 && son[u] >= (son[u] - son[v]) * 2) return 1;
  return 0;
}
void dfs2(int u) {
  vis[u] = 1;
  if (son[u] == 1) {
    zx[u] = u;
    return;
  }
  int v, z = u;
  for (int e = head[u]; e != -1; e = nex[e]) {
    v = pnt[e];
    if (!vis[v]) {
      dfs2(v);
      if (maxson[u] == son[v]) {
        z = zx[v];
      }
    }
  }
  while (!is_ok(u, z) && fa[z] != -1) {
    z = fa[z];
  }
  zx[u] = z;
}
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    Init();
    int u, v;
    for (int i = 2; i <= n; i++) {
      scanf("%d", &u);
      fa[i] = u;
      Addedge(u, i);
      Addedge(i, u);
    }
    dfs1(1);
    memset(vis, 0, sizeof(vis));
    dfs2(1);
    while (m--) {
      scanf("%d", &u);
      printf("%d\n", zx[u]);
    }
  }
  return 0;
}
