#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graph;
vector<int> sz;
vector<int> ds;
vector<int> cn;
void f1(int x) {
  if (graph[x].size() == 0) {
    sz[x] = 1;
    return;
  }
  sz[x] = 1;
  for (auto& y : graph[x]) {
    f1(y);
    sz[x] += sz[y];
  }
  for (auto& y : graph[x]) {
    if (ds[x] == -1 || sz[y] > sz[ds[x]]) {
      ds[x] = y;
    }
  }
}
void solve(int u, queue<pair<int, int>>& q) {
  if (cn[u] == -1) q.push({u, sz[u]});
  int r = 0;
  if (graph[u].size() > 0) r = 2 * sz[ds[u]];
  while (!q.empty() && (q.front().second >= r)) {
    cn[q.front().first] = u;
    q.pop();
  }
  if (graph[u].size() > 0) {
    solve(ds[u], q);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  graph.resize(n);
  int u, v;
  for (int i = 1; i < n; i++) {
    cin >> u;
    u--;
    graph[u].push_back(i);
  }
  sz.resize(n);
  ds.resize(n, -1);
  cn.resize(n, -1);
  f1(0);
  for (int i = 0; i < m; i++) {
    cin >> u;
    u--;
    if (cn[u] != -1) {
      cout << cn[u] + 1 << '\n';
    } else {
      queue<pair<int, int>> q;
      solve(u, q);
      cout << cn[u] + 1 << '\n';
    }
  }
  return 0;
}
