#include <bits/stdc++.h>
using namespace std;
int P[300010];
vector<int> adjList[300010];
int cent[300010];
int cnt[300010];
int dfs(int u) {
  cnt[u] = 1;
  cent[u] = u;
  int lc = -1;
  for (auto v : adjList[u]) {
    cnt[u] += dfs(v);
    if (lc == -1 || cnt[v] > cnt[lc]) lc = v;
  }
  if (lc == -1) return cnt[u];
  lc = cent[lc];
  while (lc != u && 2 * cnt[lc] < cnt[u]) lc = P[lc];
  cent[u] = lc;
  return cnt[u];
}
int main() {
  int N, Q;
  cin >> N >> Q;
  for (int i = 1; i < N; i++) {
    cin >> P[i];
    P[i] -= 1;
    adjList[P[i]].push_back(i);
  }
  dfs(0);
  for (int i = 0; i < Q; i++) {
    int x;
    cin >> x;
    x--;
    cout << cent[x] + 1 << endl;
  }
  return 0;
}
