#include <bits/stdc++.h>
using namespace std;
inline void chkmax(int &a, int b) {
  if (a < b) a = b;
}
const int maxn = 300000 + 10;
int n, Q, x, H = 0, T = 1;
int fa[maxn], q[maxn];
int pl[maxn], Ans[maxn], sz[maxn];
int tmp[maxn];
vector<int> g[maxn];
void add(int u, int v) { g[u].push_back(v); }
int main() {
  int i, j, k;
  scanf("%d%d", &n, &Q);
  for (i = 2; i <= n; i++) scanf("%d", &fa[i]), add(fa[i], i);
  q[1] = 1;
  while (H - T) {
    int u = q[++H];
    for (i = 0; i < g[u].size(); i++) q[++T] = g[u][i];
  }
  for (i = 1; i <= n; i++) pl[i] = i, sz[i] = 1;
  for (i = T; i >= 1; i--) {
    sz[fa[q[i]]] += sz[q[i]];
    chkmax(Ans[fa[q[i]]], sz[q[i]]);
  }
  for (k = T; k >= 1; k--) {
    int u = q[k];
    for (i = 0; i < g[u].size(); i++) {
      int v = g[u][i];
      chkmax(Ans[pl[v]], sz[u] - sz[pl[v]]);
      while (pl[v] - v) {
        int f = fa[pl[v]];
        chkmax(Ans[f], sz[u] - sz[f]);
        if (Ans[f] <= Ans[pl[v]])
          pl[v] = f;
        else
          break;
      }
      if (Ans[pl[v]] <= Ans[pl[u]]) pl[u] = pl[v];
    }
    tmp[u] = pl[u];
  }
  while (Q--) scanf("%d", &x), printf("%d\n", tmp[x]);
}
