#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T LCM(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T, typename second>
T expo(T b, second e, const T &m) {
  if (e <= 1) return e == 0 ? 1 : b;
  return (e & 1) == 0 ? expo((b * b) % m, e >> 1, m)
                      : (b * expo((b * b) % m, e >> 1, m)) % m;
}
template <typename T, typename second>
T expo(T b, second e) {
  if (e <= 1) return e == 0 ? 1 : b;
  return (e & 1) == 0 ? expo((b * b), e >> 1) : (b * expo((b * b), e >> 1));
}
template <typename T>
T modinv(T a) {
  return expo(a, 1000000007ll - 2, 1000000007ll);
}
template <class T, class second>
std::ostream &operator<<(std::ostream &os, const std::pair<T, second> &t) {
  os << "(" << t.first << ", " << t.second << ")";
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &t) {
  os << "[";
  for (__typeof(t.begin()) it = t.begin(); it != t.end(); it++) {
    if (it != t.begin()) os << ", ";
    os << *it;
  }
  os << "]";
  return os;
}
const int MAXN = 3e5 + 3;
int answers[MAXN], qs[MAXN], n, q;
bool big[MAXN];
vector<int> adj[MAXN];
int subtree[MAXN];
void walk(int r = 1) {
  subtree[r] = 1;
  for (auto &elem : adj[r]) walk(elem), subtree[r] += subtree[elem];
}
set<pair<int, int> > s;
void add(int r, int p) {
  s.insert({subtree[r], r});
  for (auto &elem : adj[r]) {
    if (elem != p && !big[elem]) add(elem, r);
  }
}
void rem(int r, int p) {
  s.erase({subtree[r], r});
  for (auto &elem : adj[r]) {
    if (elem != p && !big[elem]) rem(elem, r);
  }
}
int eval(int r) {
  auto it = s.lower_bound({(subtree[r] + 1) / 2, 0});
  return it->second;
}
void go(int r = 1, int p = -1, bool keep = true) {
  int bigchild = -1, maxim = 0;
  for (auto &elem : adj[r]) {
    if (elem != p)
      bigchild = subtree[elem] > maxim ? elem : bigchild,
      maxim = max(maxim, subtree[elem]);
  }
  for (auto &elem : adj[r]) {
    if (elem != p && elem != bigchild) {
      go(elem, r, false);
    }
  }
  if (bigchild != -1) {
    go(bigchild, r, true), big[bigchild] = true;
  }
  add(r, p);
  answers[r] = eval(r);
  if (bigchild != -1) big[bigchild] = false;
  if (!keep) {
    rem(r, p);
  }
}
int main() {
  int x;
  scanf("%d %d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &x);
    adj[x].push_back(i);
  }
  walk();
  for (int i = 0; i < q; i++) scanf("%d", &qs[i]);
  go();
  for (int i = 0; i < q; i++) {
    printf("%d\n", answers[qs[i]]);
  }
  return 0;
}
