#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
}
int n, q;
vector<int> G[maxn];
int ans[maxn][2];
int son[maxn];
int sz[maxn];
int st[maxn][30];
void dfs(int u) {
  sz[u] = 1;
  for (int i = 0; i < (int)G[u].size(); i++) {
    int v = G[u][i];
    dfs(v);
    sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
  st[u][0] = son[u];
  for (int j = 1; j <= 17; j++) st[u][j] = st[st[u][j - 1]][j - 1];
  int v = u;
  for (int j = 17; j >= 0; j--) {
    if (2 * sz[st[v][j]] > sz[u]) v = st[v][j];
  }
  ans[u][0] = v;
  if (2 * sz[son[v]] == sz[u]) ans[u][1] = son[v];
}
int main() {
  int v;
  read(n);
  read(q);
  for (int i = 2; i <= n; i++) {
    read(v);
    G[v].push_back(i);
  }
  dfs(1);
  while (q--) {
    read(v);
    printf("%d\n", ans[v][0]);
  }
  return 0;
}
