#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
inline void chmin(T &t, U f) {
  if (t > f) t = f;
}
template <class T, class U>
inline void chmax(T &t, U f) {
  if (t < f) t = f;
}
long long N, Q;
vector<long long> G[300000];
long long sz[300000];
long long par[20][300000];
long long dep[300000];
long long c[300000];
void predfs(long long v, long long p, long long d) {
  par[0][v] = p;
  dep[v] = d;
  sz[v] = 1;
  for (auto u : G[v]) {
    predfs(u, v, d + 1);
    sz[v] += sz[u];
  }
}
void dfs(long long v) {
  for (auto u : G[v]) dfs(u);
  long long w = -1;
  for (auto u : G[v]) {
    if (sz[u] * 2 > sz[v]) {
      w = u;
    }
  }
  if (w == -1) {
    c[v] = v;
    return;
  }
  w = c[w];
  if ((sz[v] - sz[w]) * 2 <= sz[v]) {
    c[v] = w;
    return;
  }
  for (long long i = 19; i >= 0; i--) {
    if (dep[w] - (1ll << i) <= dep[v]) continue;
    long long ww = par[i][w];
    if ((sz[v] - sz[ww]) * 2 <= sz[v]) continue;
    w = ww;
  }
  c[v] = par[0][w];
}
signed main() {
  scanf("%lld%lld", &N, &Q);
  for (long long i = 1; i < N; i++) {
    long long p;
    scanf("%lld", &p);
    p--;
    G[p].push_back(i);
  }
  predfs(0, -1, 0);
  for (long long i = 0; i < (19); i++) {
    for (long long j = 0; j < (N); j++) {
      if (par[i][j] == -1)
        par[i + 1][j] = -1;
      else
        par[i + 1][j] = par[i][par[i][j]];
    }
  }
  dfs(0);
  while (Q--) {
    long long v;
    scanf("%lld", &v);
    v--;
    printf("%lld\n", c[v] + 1);
  }
  return 0;
}
