#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
int n, m, fa[MAXN], sz[MAXN], f[MAXN], ans[MAXN];
vector<int> G[MAXN];
void dfs(int u) {
  sz[u] = 1;
  for (int i = 0; i < (int)G[u].size(); ++i)
    dfs(G[u][i]), sz[u] += sz[G[u][i]], f[u] = max(f[u], sz[G[u][i]]);
  int best = f[u];
  ans[u] = u;
  for (int i = 0; i < (int)G[u].size(); ++i) {
    int v = G[u][i];
    int t = ans[v], p = ans[v];
    int pre = max(f[t], sz[u] - sz[t]), now = 1000000000;
    while (fa[t] != u) {
      t = fa[t];
      now = max(f[t], sz[u] - sz[t]);
      if (now < pre)
        pre = now, p = t;
      else
        break;
    }
    if (pre < best) {
      best = pre;
      ans[u] = p;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 2; i <= n; ++i) {
    cin >> fa[i];
    G[fa[i]].push_back(i);
  }
  dfs(1);
  for (int i = 1; i <= m; ++i) {
    int u;
    cin >> u;
    cout << ans[u] << endl;
  }
  return 0;
}
