#include <bits/stdc++.h>
using namespace std;
int n, q;
int p[303030];
vector<int> G[303030];
int S[303030];
int X[303030];
void dfs1(int v) {
  S[v] = 1;
  for (int x : G[v]) {
    dfs1(x);
    S[v] += S[x];
  }
}
void dfs2(int v) {
  for (int x : G[v]) {
    dfs2(x);
  }
  int bestx = -1;
  int best = -1;
  for (int x : G[v]) {
    if (S[x] > best) {
      best = S[x];
      bestx = x;
    }
  }
  if (bestx == -1) {
    X[v] = v;
  } else {
    int x = X[bestx];
    while (2 * S[x] < S[v]) {
      x = p[x];
    }
    X[v] = x;
  }
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    cin >> p[i];
    --p[i];
    G[p[i]].push_back(i);
  }
  dfs1(0);
  dfs2(0);
  for (int i = 0; i < q; ++i) {
    int v;
    cin >> v;
    --v;
    cout << X[v] + 1 << '\n';
  }
  return 0;
}
