#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
const int N = 3e5 + 5;
V<int> G[N];
int sz[N], fa[N], son[N];
void dfs(int u) {
  sz[u] = 1;
  for (auto& v : G[u]) {
    dfs(v);
    sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
}
int ans[N];
int getSub(int rt, int x) {
  if (!son[x]) return sz[rt] - sz[x];
  return max(sz[son[x]], sz[rt] - sz[x]);
}
void solve(int u) {
  for (auto& v : G[u]) {
    solve(v);
  }
  ans[u] = u;
  int sonSz = sz[son[u]];
  for (auto& v : G[u]) {
    int x = ans[v];
    if (getSub(u, x) < sonSz) {
      ans[u] = x, sonSz = getSub(u, x);
    }
    while (fa[x] != u) {
      if (getSub(u, fa[x]) > getSub(u, x)) break;
      if (getSub(u, fa[x]) < sonSz) {
        ans[u] = fa[x], sonSz = getSub(u, fa[x]);
      }
      x = fa[x];
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int p;
    cin >> p, G[p].push_back(i), fa[i] = p;
  }
  dfs(1), solve(1);
  while (q--) {
    int x;
    cin >> x;
    cout << ans[x] << "\n";
  }
}
