#include <bits/stdc++.h>
using namespace std;
const int maxn = int(3e5) + 5, inf = int(1e9) + 5;
int H[maxn], sz[maxn], start[maxn], en[maxn], res[maxn];
pair<int, int> st[4 * maxn];
vector<pair<pair<int, int>, int>> Q;
vector<int> dis, graph[maxn];
inline int left(int node) { return (node << 1); }
inline int right(int node) { return (node << 1) + 1; }
void upd(int node, int L, int R, int idx, pair<int, int> v) {
  if (L == R) {
    st[node] = v;
  } else {
    if (idx <= (L + R) / 2)
      upd(left(node), L, (L + R) / 2, idx, v);
    else
      upd(right(node), (L + R) / 2 + 1, R, idx, v);
    st[node] = max(st[left(node)], st[right(node)]);
  }
}
pair<int, int> qry(int node, int L, int R, int a, int b) {
  if (a > R || b < L)
    return {-inf, -inf};
  else if (a <= L && R <= b)
    return st[node];
  else
    return max(qry(left(node), L, (L + R) / 2, a, b),
               qry(right(node), (L + R) / 2 + 1, R, a, b));
}
void dfs(int node, int ht) {
  sz[node] = 1, H[node] = ht;
  start[node] = int(dis.size());
  dis.push_back(node);
  for (auto it : graph[node]) {
    dfs(it, ht + 1);
    sz[node] += sz[it];
  }
  en[node] = int(dis.size()) - 1;
}
int main(void) {
  int n, q, p, node;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < 4 * maxn; i++) st[i] = {-inf, -inf};
  for (int i = 1; i < n; i++) {
    scanf("%d", &p);
    p--;
    graph[p].push_back(i);
  }
  dfs(0, 0);
  for (int i = 0; i < q; i++) {
    scanf("%d", &node);
    node--;
    Q.push_back({{sz[node] / 2, node}, i});
  }
  vector<pair<int, int>> szs;
  for (int i = 0; i < n; i++) szs.push_back({sz[i], i});
  sort(szs.rbegin(), szs.rend()), sort(Q.rbegin(), Q.rend());
  int ptr = 0;
  for (auto it : Q) {
    if (ptr != n) {
      while (szs[ptr].first > it.first.first) {
        int node = szs[ptr].second;
        upd(1, 0, int(dis.size()) - 1, start[node], {H[node], node});
        ptr++;
        if (ptr == n) break;
      }
    }
    res[it.second] = qry(1, 0, int(dis.size()) - 1, start[it.first.second],
                         en[it.first.second])
                         .second;
  }
  for (int i = 0; i < q; i++) printf("%d\n", res[i] + 1);
}
