#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010;
int inp[maxn];
int reach[maxn], ans[maxn], bigg[maxn];
vector<vector<int> > g(maxn, vector<int>());
void make(int n) {
  for (int i = 2; i <= n; i++) {
    int v = inp[i];
    g[v].push_back(i);
  }
}
int dfs(int u) {
  int temp = 0, tx = 1, tot = INT_MIN;
  const vector<int>& v = g[u];
  for (int i = 0; i < v.size(); i++) {
    int s = v[i];
    int x = dfs(s);
    tx += x;
    if (tot < x) {
      tot = x;
      temp = s;
    }
  }
  reach[u] = tx;
  bigg[u] = bigg[temp];
  return reach[u];
}
bool valid(int u, int p) {
  if ((reach[u] - reach[p]) * 2 <= reach[u] && bigg[p] * 2 <= reach[u])
    return true;
  return false;
}
void dfs_centroid(int u) {
  if (reach[u] == 1)
    ans[u] = u;
  else {
    const vector<int>& v = g[u];
    int ptr = 0, tmp = INT_MIN;
    for (int i = 0; i < v.size(); i++) {
      int s = v[i];
      dfs_centroid(s);
      if (reach[s] > tmp) {
        tmp = reach[s];
        ptr = s;
      }
    }
    int c = ans[ptr];
    while (!valid(u, c)) {
      c = inp[c];
    }
    ans[u] = c;
  }
}
int main() {
  int n, q, v;
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) scanf("%d", inp + i);
  make(n);
  dfs(1);
  inp[1] = 1;
  dfs_centroid(1);
  for (int i = 0; i < q; i++) {
    scanf("%d", &v);
    printf("%d\n", ans[v]);
  }
  return 0;
}
