#include <bits/stdc++.h>
using namespace std;
int ans[1000 * 310], v, n, q, H, h[1000 * 310], p[21][1000 * 310],
    s[1000 * 310], g[1000 * 310];
vector<int> a[1000 * 310];
int calc(int v, int pr = 0) {
  s[v] = 1;
  p[0][v] = pr;
  h[v] = ++H;
  for (int i = 1; i <= 20; i++) p[i][v] = p[i - 1][p[i - 1][v]];
  for (int i = 0; i < a[v].size(); i++) {
    if (a[v][i] == pr) continue;
    s[v] += calc(a[v][i], v);
    g[v] = max(s[a[v][i]], g[v]);
  }
  H--;
  return s[v];
}
void dfs(int v, int pr = 0) {
  int l, r, lv = v, rv = v;
  for (int i = 20; i >= 0; i--) {
    r = p[i][lv];
    if (r && (s[r] - s[v]) * 2 <= (s[r])) lv = r;
    l = p[i][rv];
    if (l && g[v] * 2 > (s[l])) rv = l;
  }
  l = rv;
  if (g[v] * 2 > s[l]) l = p[0][l];
  while (l && g[v] * 2 <= (s[l]) && (s[l] - s[v]) * 2 <= (s[l])) {
    ans[l] = v;
    l = p[0][l];
  }
  for (int i = 0; i < a[v].size(); i++) {
    if (a[v][i] == pr) continue;
    dfs(a[v][i], v);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    cin >> v;
    a[i].push_back(v);
    a[v].push_back(i);
  }
  calc(1);
  dfs(1);
  for (int i = 1; i <= q; i++) {
    cin >> v;
    cout << ans[v] << "\n";
  }
}
