#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const long long INF = 1e18;
long long power(long long x, long long y) {
  long long t = 1;
  while (y > 0) {
    if (y % 2)
      y -= 1, t = t * x % mod;
    else
      y /= 2, x = x * x % mod;
  }
  return t;
}
int par[N][25];
int sub[N], depth[N], A[N], mx[N];
vector<int> G[N];
void dfs(int i, int d) {
  depth[i] = d;
  sub[i] = 1;
  mx[i] = 0;
  for (int j = 0; j < G[i].size(); ++j) {
    dfs(G[i][j], d + 1);
    mx[i] = max(mx[i], sub[G[i][j]]);
    sub[i] += sub[G[i][j]];
  }
}
void find(int nod) {
  int u = nod, p = nod;
  for (int i = 24; i >= 0; i--) {
    if (sub[par[u][i]] >= 2 * mx[nod]) {
      p = par[u][i];
    } else
      u = par[u][i];
  }
  if (sub[nod] >= 2 * mx[nod]) p = nod;
  while (true) {
    if (sub[p] >= 2 * mx[nod]) {
      if (sub[p] >= 2 * (sub[p] - sub[nod])) {
        A[p] = nod;
        if (p == 0) break;
        p = par[p][0];
      } else
        break;
    } else
      break;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int q;
  scanf("%d", &q);
  for (int i = 0; i < n - 1; ++i) {
    int x;
    scanf("%d", &x);
    x--;
    par[i + 1][0] = x;
    G[x].push_back(i + 1);
  }
  dfs(0, 0);
  for (int i = 1; i < 25; ++i)
    for (int j = 0; j < n; ++j) par[j][i] = par[par[j][i - 1]][i - 1];
  for (int i = 0; i < n; ++i) {
    find(i);
  }
  for (int i = 0; i < q; ++i) {
    int x;
    scanf("%d", &x);
    printf("%d\n", A[x - 1] + 1);
  }
  return 0;
}
