#include <bits/stdc++.h>
using namespace std;
int n, q;
vector<int> g[300055];
int subsize[300055], high[300055];
int can[300055], remain[300055];
int res[300055];
map<int, int> c[300055];
void mer(int u, int v) {
  if (c[u].size() < c[v].size()) {
    c[u].swap(c[v]);
  }
  for (auto ite : c[v]) {
    if (c[u].find(ite.first) == c[u].end()) {
      c[u][ite.first] = ite.second;
      auto diu = c[u].upper_bound(ite.first);
      if (diu == c[u].end()) continue;
      if (high[diu->second] >= high[ite.second]) c[u].erase(diu, c[u].end());
    }
    int t1 = high[c[u][ite.first]], t2 = high[ite.second];
    if (t2 < t1) c[u][ite.first] = ite.second;
    auto diu = c[u].upper_bound(ite.first);
    if (diu == c[u].end()) continue;
    if (high[diu->second] >= high[c[u][ite.first]]) c[u].erase(diu, c[u].end());
  }
}
void dfs(int v) {
  subsize[v] = 1;
  for (auto u : g[v]) {
    dfs(u);
    high[v] = max(high[v], subsize[u]);
    subsize[v] += subsize[u];
  }
  remain[v] = n - subsize[v];
  c[v][remain[v]] = v;
  for (auto u : g[v]) {
    mer(v, u);
  }
  if (high[v] <= subsize[v] / 2 || res[v] != 0) return;
  res[v] = (--c[v].upper_bound(subsize[v] / 2 + remain[v]))->second;
}
int main() {
  scanf("%d %d", &n, &q);
  int x;
  for (int i = 1; i < n; i++) {
    scanf("%d", &x);
    x--;
    g[x].emplace_back(i);
  }
  dfs(0);
  while (q--) {
    scanf("%d", &x);
    x--;
    if (high[x] <= subsize[x] / 2) {
      printf("%d\n", x + 1);
      continue;
    }
    printf("%d\n", res[x] + 1);
  }
  return 0;
}
