#include <bits/stdc++.h>
using namespace std;
vector<int> v[312345];
int dad[312345];
int sz[312345];
int mx[312345];
int cut[312345];
void dfsCount(int x) {
  int vs = v[x].size();
  for (int i = 0; i < vs; i++) {
    int y = v[x][i];
    dfsCount(y);
    sz[x] += sz[y];
    mx[x] = max(mx[x], sz[y]);
  }
  sz[x]++;
}
void dfs(int x) {
  int vs = v[x].size();
  if (vs == 0) {
    cut[x] = x;
    return;
  }
  for (int i = 0; i < vs; i++) {
    int y = v[x][i];
    dfs(y);
    if (cut[x] == 0) {
      int c = cut[y];
      while (c != x) {
        int now = max(mx[c], sz[x] - sz[c]);
        if (now <= sz[x] / 2) {
          cut[x] = c;
          break;
        }
        c = dad[c];
      }
    }
  }
  if (cut[x] == 0) cut[x] = x;
}
int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int p;
    cin >> p;
    v[p].push_back(i);
    dad[i] = p;
  }
  dfsCount(1);
  dfs(1);
  {}
  for (int i = 1; i <= q; i++) {
    int x;
    cin >> x;
    cout << cut[x] << "\n";
  }
  return 0;
}
