#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
using namespace std;
const double eps = 0.000001;
const long double pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const long long MOD = 1e18 + 9;
const long long INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;
const int PRI = 555557;
const int pri = 997;
int tests = 1;
int n, m, q;
int sz[N], pr[N], ans[N];
bool u[N];
vector<int> g[N];
void dfs(int v, int p = 1) {
  sz[v] = 1;
  pr[v] = p;
  for (int to : g[v]) {
    if (to == p) continue;
    dfs(to, v);
    sz[v] += sz[to];
  }
}
void dfs_center(int v) {
  u[v] = 1;
  if (sz[v] == 1) {
    ans[v] = v;
    return;
  }
  int mx = g[v].back();
  for (int to : g[v]) {
    if (u[to]) continue;
    dfs_center(to);
    if (sz[mx] < sz[to]) {
      mx = to;
    }
  }
  int c = ans[mx];
  while (sz[v] > sz[c] * 2) {
    c = pr[c];
  }
  ans[v] = c;
}
inline void Solve() {
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    g[x].push_back(i);
  }
  dfs(1);
  dfs_center(1);
  while (q--) {
    int x;
    cin >> x;
    cout << ans[x] << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  while (tests--) {
    Solve();
  }
  return 0;
}
