#include <bits/stdc++.h>
using namespace std;
long long powmod(long long a, long long b, long long MOD) {
  long long res = 1;
  a %= MOD;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}
const int maxn = 3e5 + 10;
const int maxq = 3e5 + 10;
int n, q;
int sum[maxn], fa[maxn], cent[maxn];
vector<int> ch[maxn];
int calc(int x) {
  if (sum[x] != 0) return sum[x];
  if (ch[x].empty()) return sum[x] = 1;
  for (int i = 0; i < ch[x].size(); ++i) sum[x] += calc(ch[x][i]);
  return ++sum[x];
}
int solve(int x) {
  if (cent[x] != 0) return cent[x];
  for (int i = 0; i < ch[x].size(); ++i) {
    int v = ch[x][i];
    if (sum[v] > sum[x] / 2.0) {
      int c = solve(v);
      while (sum[c] <= sum[x] / 2.0) c = fa[c];
      return cent[x] = c;
    }
  }
  return cent[x] = x;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i < n + 1; ++i) {
    int d;
    scanf("%d", &d);
    fa[i] = d;
    ch[d].push_back(i);
  }
  calc(1);
  for (int i = 0; i < q; ++i) {
    int d;
    scanf("%d", &d);
    printf("%d\n", solve(d));
  }
  calc(1);
  return 0;
}
