#include <bits/stdc++.h>
const long long md = 1e9 + 7;
const long long Inf = 1e9;
const long long Inf64 = 1e18;
const long long MaxN = 3e5 + 100;
const long long LogN = 20;
const long long MaxM = 5e5 + 10;
const double eps = 1e-3;
const int dx[8] = {1, -1, 2, 2, -1, 1, -2, -2};
const int dy[8] = {2, 2, 1, -1, -2, -2, 1, -1};
const int ddx[4] = {1, 1, -1, -1};
const int ddy[4] = {1, -1, 1, -1};
const double Pi = acos(-1);
using namespace std;
template <typename T>
istream &operator>>(istream &in, pair<T, T> &a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, pair<T, T> a) {
  out << a.first << ' ' << a.second;
  return out;
}
template <typename T>
istream &operator>>(istream &in, vector<T> &Mt) {
  for (T &a : Mt) in >> a;
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> Mt) {
  for (int i = 0; i < (int)Mt.size(); i++) {
    out << Mt[i];
    if (i != (int)Mt.size()) out << ' ';
  }
  out << '\n';
  return out;
}
inline long long Mod(long long &a, long long m = md) {
  while (a >= m) a -= m;
  return a;
}
inline long long gcd(long long a, long long b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}
inline long long gcdex(long long a, long long mod = md) {
  long long g = mod, r = a, x = 0, y = 1;
  while (r != 0) {
    long long q = g / r;
    g %= r;
    swap(g, r);
    x -= q * y;
    swap(x, y);
  }
  return x < 0 ? x + mod : x;
}
inline long long binpow(long long a, long long n, long long m = md) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res *= a;
      res %= m;
    }
    a *= a;
    a %= m;
    n >>= 1;
  }
  return res % md;
}
vector<long long> Gr[MaxN];
long long Ans[MaxN];
set<pair<long long, long long> > dfs(long long v, long long p = -1) {
  set<pair<long long, long long> > St;
  for (long long to : Gr[v]) {
    if (to == p) continue;
    set<pair<long long, long long> > s = dfs(to, v);
    if ((int)St.size() < (int)s.size()) swap(St, s);
    for (pair<long long, long long> a : s) St.insert(a);
  }
  St.insert({(int)St.size() + 1, v});
  Ans[v] = St.lower_bound({((int)St.size() + 1) / 2, 0})->second;
  return St;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  {
    long long N, M;
    cin >> N >> M;
    for (int i = 1; i < N; i++) {
      long long a;
      cin >> a;
      a--;
      Gr[a].push_back(i);
      Gr[i].push_back(a);
    }
    dfs(0);
    for (int i = 0; i < M; i++) {
      long long a;
      cin >> a;
      a--;
      cout << Ans[a] + 1 << ' ';
    }
  }
END:
  return 0;
}
