#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
int n, q;
int par[300010];
int sz[300010], centroid[300010];
void ComputeSize(int u) {
  for (int i = 0; i < adj[u].size(); ++i) {
    ComputeSize(adj[u][i]);
    sz[u] += sz[adj[u][i]];
  }
  sz[u]++;
}
void ComputeCentroid(int u) {
  if (sz[u] == 1) {
    centroid[u] = u;
    return;
  }
  int largest = adj[u][0];
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i];
    ComputeCentroid(v);
    largest = sz[largest] < sz[v] ? v : largest;
  }
  int half = sz[u] - sz[u] / 2;
  int cur = centroid[largest];
  while (cur != u) {
    if (sz[cur] < half) {
      cur = par[cur];
    } else
      break;
  }
  centroid[u] = cur;
}
int main() {
  scanf("%d%d", &n, &q);
  adj.resize(n + 2);
  for (int i = 1; i < n; ++i) {
    scanf("%d", &par[i]);
    par[i]--;
    adj[par[i]].push_back(i);
  }
  par[0] = -1;
  ComputeSize(0);
  ComputeCentroid(0);
  int u;
  for (int i = 0; i < q; ++i) {
    scanf("%d", &u);
    printf("%d\n", centroid[u - 1] + 1);
  }
  return 0;
}
