#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
const int MaxN = 300 * 1000;
vector<int> g[MaxN + 10];
int par[MaxN + 10];
int centroid[MaxN + 10];
int sons[MaxN + 10];
void calcSons(int v) {
  sons[v] = 1;
  int max_w = 0;
  for (int w : g[v]) {
    calcSons(w);
    sons[v] += sons[w];
    if (sons[w] > sons[max_w]) max_w = w;
  }
  if (g[v].empty())
    centroid[v] = v;
  else {
    int n = sons[v] / 2;
    if (sons[max_w] <= n)
      centroid[v] = v;
    else {
      int w = centroid[max_w];
      while (w != v) {
        if (sons[v] - sons[centroid[w]] <= n) {
          w = centroid[w];
          break;
        }
        if (sons[v] - sons[w] <= n) break;
        w = par[w];
      }
      centroid[v] = w;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    cin >> par[i];
    g[par[i]].push_back(i);
  }
  calcSons(1);
  int v;
  for (int Q = 0; Q < q; Q++) {
    cin >> v;
    cout << centroid[v] << endl;
  }
  return 0;
}
