#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
class Graph {
 public:
  int vn;
  int sumcost = 0;
  vector<vector<pair<int, int>>> g;
  Graph(int n) {
    vn = n;
    g.resize(n);
  }
  virtual void con(int a, int b, int w) = 0;
  int getWeight(int f, int t) {
    auto itr = lower_bound((g[f]).begin(), (g[f]).end(), make_pair(t, INT_MIN));
    if (itr != g[f].end()) return itr->second;
    return INT_MIN;
  }
  int Costsum() { return sumcost; }
  void scan(int edcount, bool oindexed, bool w) {
    for (int i = (0); (edcount) > i; i++) {
      int a, b, c = 1;
      scanf("%d %d", &a, &b);
      if (w) scanf("%d", &c);
      con(a - oindexed, b - oindexed, c);
    }
  }
};
class BiDGraph : public Graph {
 public:
  BiDGraph(int n) : Graph(n) {}
  void con(int a, int b, int w = 1) {
    g[a].push_back({b, w});
    g[b].push_back({a, w});
    sumcost++;
  }
};
class DGraph : public Graph {
 public:
  DGraph(int n) : Graph(n) {}
  void con(int a, int b, int w = 1) {
    g[a].push_back({b, w});
    sumcost++;
  }
};
class Heavy_Light_Decomposition {
 public:
  BiDGraph g, compg;
  vector<int> bsz, sz, depth, chain, par;
  int bn = 0;
  vector<int> bvn, inbn;
  vector<vector<int>> bv;
  Heavy_Light_Decomposition(BiDGraph graph, int root)
      : g(graph),
        compg(graph.vn),
        sz(graph.vn, 1),
        bsz(graph.vn),
        depth(graph.vn),
        chain(graph.vn),
        par(graph.vn),
        bvn(graph.vn),
        inbn(graph.vn) {
    getsz(root, root);
    bv.push_back(vector<int>());
    HLD(root, -1, root, 0);
  }
  int getsz(int cur, int p) {
    par[cur] = p;
    for (auto itr : g.g[cur])
      if (p != itr.first)
        depth[itr.first] = depth[cur] + 1, sz[cur] += getsz(itr.first, cur);
    return sz[cur];
  }
  void HLD(int cur, int p, int head, int num) {
    chain[cur] = head, bvn[cur] = num;
    inbn[cur] = bv[num].size(), bv[num].push_back(cur);
    pair<int, int> Maxc = {-1, -1};
    for (auto itr : g.g[cur])
      if (itr.first != p) Maxc = max(Maxc, {sz[itr.first], itr.first});
    bsz[cur] = Maxc.first;
    for (auto itr : g.g[cur])
      if (itr.first != p) {
        int nb = num;
        if (itr.first != Maxc.second) {
          bv.push_back(vector<int>());
          nb = ++bn;
        }
        HLD(itr.first, cur, itr.first == Maxc.second ? head : itr.first, nb);
      }
  }
  int lca(int a, int b) {
    if (chain[a] == chain[b]) return depth[a] < depth[b] ? a : b;
    if (depth[chain[a]] > depth[chain[b]]) return lca(par[chain[a]], b);
    return lca(a, par[chain[b]]);
  }
  void for_each_edge(int a, int b, function<void(int, int)> func) {
    if (chain[a] == chain[b])
      return func(inbn[a] < inbn[b] ? a : b, inbn[a] < inbn[b] ? b : a);
    if (depth[chain[a]] < depth[chain[b]]) swap(a, b);
    for_each_edge(a, chain[a], func), for_each_edge(par[chain[a]], b, func);
  }
};
class SegmentTree {
 public:
  vector<int> data;
  int n = 1;
  SegmentTree(int a) {
    while (n < a) n *= 2;
    data = vector<int>(n * 2 - 1, LLONG_MAX);
  }
  void update(int p, int a) {
    int cur = p + n - 1;
    data[cur] = a;
    do {
      cur = (cur - 1) / 2;
      data[cur] = min(data[cur], a);
    } while (cur);
  }
  int RMQ(int a, int b, int num = 0, int base = 1) {
    int l = (num + 1 - base) * (n / base), r = l + n / base;
    if (a == l && b == r) return data[num];
    int nr = (l + r) / 2;
    int ret = LLONG_MAX;
    if (nr > a) ret = min(ret, RMQ(a, min(b, nr), num * 2 + 1, base * 2));
    if (nr < b) ret = min(ret, RMQ(max(a, nr), b, num * 2 + 2, base * 2));
    return ret;
  }
};
signed main() {
  int n, k;
  scanf("%d %d", &n, &k);
  BiDGraph g(n);
  for (int i = (0); (n - 1) > i; i++) {
    int a;
    scanf("%d", &a);
    g.con(i + 1, a - 1);
  }
  Heavy_Light_Decomposition hld(g, 0);
  vector<vector<int>> bsv(hld.bv.size());
  for (int i = (0); (hld.bv.size()) > i; i++) {
    bsv[i].resize(hld.bv[i].size());
    for (int j = (0); (hld.bv[i].size()) > j; j++) {
      bsv[i][j] = hld.bsz[hld.bv[i][j]];
    }
  }
  for (int i = (0); (k) > i; i++) {
    int q;
    scanf("%d", &q);
    q--;
    int p = lower_bound((bsv[hld.bvn[q]]).begin(), (bsv[hld.bvn[q]]).end(),
                        hld.sz[q] / 2, greater<int>()) -
            bsv[hld.bvn[q]].begin();
    printf("%d\n", hld.bv[hld.bvn[q]][p] + 1);
  }
  return 0;
}
