#include <bits/stdc++.h>
using std::max;
using std::set;
using std::vector;
template <class type>
inline const void read(type &in) {
  in = 0;
  char ch(getchar());
  while (ch < 48 || ch > 57) ch = getchar();
  while (ch > 47 && ch < 58)
    in = (in << 3) + (in << 1) + (ch & 15), ch = getchar();
}
const int N(3e5 + 5);
int n, m, ans[N], size[N], maxw[N];
vector<int> son[N];
struct tree {
  set<int> id;
  tree *lson, *rson;
  void *operator new(size_t size);
  inline tree() {}
  inline const void insert(const int &l, const int &r, const int &k,
                           const int &v) {
    id.insert(v);
    if (l == r) return;
    const int mid(l + r >> 1);
    if (k <= mid)
      lson->insert(l, mid, k, v);
    else
      rson->insert(mid + 1, r, k, v);
  }
  inline const void remove(const int &l, const int &r, const int &k,
                           const int &v) {
    id.erase(v);
    if (l == r) return;
    const int mid(l + r >> 1);
    if (k <= mid)
      lson->remove(l, mid, k, v);
    else
      rson->remove(mid + 1, r, k, v);
  }
  inline const void query(const int &l, const int &r, const int &L,
                          const int &R, const int &k) {
    if (l > R || r < L) return;
    if (l >= L && r <= R) {
      for (set<int>::iterator i(id.begin()); i != id.end(); i++) ans[*i] = k;
      return;
    }
    const int mid(l + r >> 1);
    lson->query(l, mid, L, R, k);
    rson->query(mid + 1, r, L, R, k);
  }
} * root;
char memory_pool[N * sizeof(tree) << 1],
    *tail(memory_pool + sizeof(memory_pool));
inline void *tree::operator new(size_t size) { return tail -= size; }
inline const void build(tree *&p, const int &l, const int &r) {
  p = new tree;
  if (l == r) return;
  const int mid(l + r >> 1);
  build(p->lson, l, mid);
  build(p->rson, mid + 1, r);
}
inline const void get_size(const int &p) {
  size[p] = 1;
  for (vector<int>::iterator i(son[p].begin()); i != son[p].end(); i++)
    get_size(*i), size[p] += size[*i], maxw[p] = max(maxw[p], size[*i]);
}
inline const void dfs(const int &p) {
  root->insert(1, n, size[p], p);
  root->query(1, n, maxw[p] << 1, size[p] << 1, p);
  for (vector<int>::iterator i(son[p].begin()); i != son[p].end(); i++) dfs(*i);
  root->remove(1, n, size[p], p);
}
int main() {
  read(n);
  read(m);
  for (int fa, i(2); i <= n; i++) read(fa), son[fa].push_back(i);
  get_size(1);
  build(root, 1, n);
  dfs(1);
  for (int x; m--;) read(x), printf("%d\n", ans[x]);
  return 0;
}
