#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010;
vector<int> graph[maxn];
int parent[maxn];
int size[maxn];
int bigsub[maxn];
int centroid[maxn];
void dfs(int u) {
  size[u] = 1;
  bigsub[u] = 0;
  for (int i = 0; i < graph[u].size(); i++) {
    int x = graph[u][i];
    dfs(x);
    size[u] += size[x];
    bigsub[u] = max(bigsub[u], size[x]);
  }
}
bool check(int u, int c) {
  return ((size[u] - size[c]) * 2 <= size[u] && (bigsub[c] * 2) <= size[u]);
}
void calc(int u) {
  if (size[u] == 1) {
    centroid[u] = u;
  } else {
    int idx = 0;
    for (int i = 0; i < graph[u].size(); i++) {
      int x = i;
      calc(graph[u][x]);
      if (size[graph[u][idx]] < size[graph[u][x]]) {
        idx = x;
      }
    }
    int c = centroid[graph[u][idx]];
    while (!check(u, c)) {
      c = parent[c];
    }
    centroid[u] = c;
  }
}
int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    int x;
    cin >> x;
    graph[x - 1].push_back(i);
    parent[i] = x - 1;
  }
  dfs(0);
  calc(0);
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    cout << centroid[x - 1] + 1 << "\n";
  }
  return 0;
}
