#include <bits/stdc++.h>
int parent[(int)(3e5 + 1)], siz[(int)(3e5 + 1)], cent[(int)(3e5 + 1)];
using namespace std;
void dfs(vector<vector<int>>& g, int u) {
  siz[u] = 1;
  int mx = -1;
  int mu = -1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    dfs(g, v);
    if (mx < siz[v]) {
      mx = siz[v];
      mu = v;
    }
    siz[u] += siz[v];
  }
  if (mx == -1) {
    cent[u] = u;
    return;
  }
  int cx = cent[mu];
  while (siz[cx] < (siz[u] - siz[u] / 2)) {
    cx = parent[cx];
  }
  cent[u] = cx;
}
int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int u;
    cin >> u;
    u--;
    parent[i + 1] = u;
    g[u].push_back(i + 1);
  }
  dfs(g, 0);
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    cout << cent[x - 1] + 1 << endl;
  }
}
