#include <bits/stdc++.h>
using namespace std;
vector<int> adj[300010];
int n, q;
int p[300111];
int sub[300111], ans[300111], bq[300111];
void dfss(int x) {
  sub[x] = 1;
  int u, l, i;
  u = -1;
  for (i = 0; i < adj[x].size(); i++) {
    dfss(adj[x][i]);
    sub[x] += (sub[adj[x][i]]);
  }
  for (i = 0; i < adj[x].size(); i++) {
    if (sub[adj[x][i]] * 2 > sub[x]) {
      u = adj[x][i];
    }
  }
  if (u == -1) {
    ans[x] = x;
  } else {
    l = ans[u];
    while ((sub[x] - sub[l]) * 2 > sub[x]) {
      l = p[l];
    }
    ans[x] = l;
  }
  return;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &p[i]);
    adj[p[i]].push_back(i);
  }
  dfss(1);
  for (int i = 0; i < q; i++) {
    scanf("%d", &bq[i]);
  }
  for (int i = 0; i < q; i++) {
    printf("%d\n", ans[bq[i]]);
  }
  return 0;
}
