#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
vector<int> g[300005];
bool vis[300005];
int child[300005];
int mostchild[300005], par[300005];
int dfs(int u) {
  vis[u] = true;
  child[u]++;
  for (int i = 0; i < g[u].size(); i++) {
    if (!vis[g[u][i]]) {
      vis[g[u][i]] = true;
      int x = dfs(g[u][i]);
      child[u] += x;
      if (child[mostchild[u]] < x) mostchild[u] = g[u][i];
    }
  }
  return child[u];
}
int res[300005];
void traverse(int u) {
  if (u == 0) return;
  vis[u] = true;
  if (child[u] == 1) {
    res[u] = u;
    return;
  }
  traverse(mostchild[u]);
  if (2 * child[mostchild[u]] > child[u]) {
    int m = res[mostchild[u]];
    while (2 * (child[u] - child[m]) > child[u]) m = par[m];
    res[u] = m;
  } else
    res[u] = u;
}
int main() {
  int n, q;
  cin >> n >> q;
  par[1] = 1;
  for (int i = 2; i < n + 1; i++) {
    scanf("%d", &par[i]);
    g[par[i]].push_back(i);
  }
  memset(vis, false, sizeof(vis));
  memset(mostchild, 0, sizeof(mostchild));
  child[0] = 0;
  dfs(1);
  memset(vis, false, sizeof(vis));
  for (int i = 1; i < n + 1; i++) {
    if (!vis[i]) traverse(i);
  }
  for (int i = 0; i < q; i++) {
    int a;
    scanf("%d", &a);
    printf("%d\n", res[a]);
  }
  return 0;
}
