#include <bits/stdc++.h>
using namespace std;
int n, pr[300010], s[300010], m[300010], q;
vector<int> a[300010];
int ced[300010];
void dfs(int u) {
  s[u] = 1;
  m[u] = 0;
  for (int i = 0; i < a[u].size(); i++) {
    int v = a[u][i];
    dfs(v);
    s[u] += s[v];
    m[u] = max(m[u], s[v]);
  }
}
bool is_cen(int v, int u) {
  if ((s[u] - s[v]) * 2 <= s[u] && m[v] * 2 <= s[u]) return true;
  return false;
}
void solve(int u) {
  if (s[u] == 1) {
    ced[u] = u;
    return;
  }
  int p = a[u][0];
  for (int i = 0; i < a[u].size(); i++) {
    int v = a[u][i];
    solve(a[u][i]);
    if (s[v] > s[p]) {
      p = v;
    }
  }
  int c = ced[p];
  while (!is_cen(c, u)) {
    c = pr[c];
  }
  ced[u] = c;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    pr[i] = x;
    a[x].push_back(i);
  }
  dfs(1);
  solve(1);
  for (int i = 1; i <= q; i++) {
    int x;
    cin >> x;
    cout << ced[x] << "\n";
  }
}
