#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
const int maxn = 500001;
int ans[maxn], sz[maxn];
pair<int, int> f[maxn];
int n, q, x;
int father[maxn];
vector<int> g[maxn];
void dfs(int k) {
  sz[k] = 1;
  for (int i = 0; i < g[k].size(); i++) {
    int v = g[k][i];
    dfs(v);
    f[k] = max(f[k], pair<int, int>(sz[v], v));
    sz[k] += sz[v];
  }
  if (f[k].second == 0)
    ans[k] = k;
  else
    ans[k] = ans[f[k].second];
  while (ans[k] != k && 2 * sz[ans[k]] < sz[k]) ans[k] = father[ans[k]];
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &x);
    father[i] = x;
    g[x].push_back(i);
  }
  dfs(1);
  for (int i = 1; i <= q; i++) {
    scanf("%d", &x);
    printf("%d\n", ans[x]);
  }
}
