#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, q;
vector<int> g[300100];
int cnt[300100], val[300100];
vector<pair<pair<int, int>, pair<int, int> > > t[4 * 300300];
int L[300300], R[300300];
vector<int> order;
void dfs(int v, int par) {
  cnt[v] = 1;
  val[v] = -inf;
  order.push_back(v);
  L[v] = (int)order.size() - 1;
  for (__typeof(g[v].begin()) it = g[v].begin(); it != g[v].end(); it++) {
    int to = *it;
    if (to != par) {
      dfs(to, v);
      cnt[v] += cnt[to];
      val[v] = max(val[v], cnt[to]);
    }
  }
  R[v] = (int)order.size() - 1;
}
vector<pair<pair<int, int>, pair<int, int> > > merge(
    vector<pair<pair<int, int>, pair<int, int> > > &a,
    vector<pair<pair<int, int>, pair<int, int> > > &b, int addb) {
  vector<pair<pair<int, int>, pair<int, int> > > c;
  int i, j;
  for (i = 0, j = 0; i < a.size() && j < b.size();) {
    if (a[i] < b[j]) {
      c.push_back(a[i++]);
    } else {
      c.push_back(make_pair(
          b[j].first, make_pair(b[j].second.first, b[j].second.second + addb)));
      j++;
    }
  }
  while (i < a.size()) {
    c.push_back(a[i++]);
  }
  while (j < b.size()) {
    c.push_back(make_pair(
        b[j].first, make_pair(b[j].second.first, b[j].second.second + addb)));
    j++;
  }
  int x = -inf;
  int ind = -1;
  for (int i = 0; i < c.size(); i++) {
    if (c[i].second.first > x) {
      x = c[i].second.first;
      ind = c[i].second.second;
    }
    c[i].second = make_pair(x, ind);
  }
  return c;
}
void build(int v, int tl, int tr) {
  if (tl == tr) {
    int x = order[tl];
    t[v].push_back(make_pair(make_pair(val[x], cnt[x]), make_pair(cnt[x], 0)));
  } else {
    int mid = (tl + tr) >> 1;
    build(2 * v, tl, mid);
    build(2 * v + 1, mid + 1, tr);
    t[v] = merge(t[2 * v], t[2 * v + 1], mid + 1 - tl);
  }
}
void print(int v, int tl, int tr) {
  printf("%d - %d %d == ", v, tl, tr);
  for (int i = 0; i < t[v].size(); i++) {
    printf("[(%d, %d), %d.%d] ", t[v][i].first.first, t[v][i].first.second,
           t[v][i].second.first, t[v][i].second.second);
  }
  printf("\n");
  if (tl == tr) {
    return;
    int x = order[tl];
  } else {
    int mid = (tl + tr) >> 1;
    print(2 * v, tl, mid);
    print(2 * v + 1, mid + 1, tr);
  }
}
int get(vector<pair<pair<int, int>, pair<int, int> > > &a, int x, int y) {
  if (a.empty()) return -1;
  if (a[0].first.first > x) return -1;
  int pos = 0;
  int l = 1, r = (int)a.size() - 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (a[mid].first.first <= x) {
      pos = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  if (a[pos].second.first >= y) return a[pos].second.second;
  return -1;
}
int get(int v, int tl, int tr, int l, int r, int x, int y) {
  if (l > r) return -1;
  if (r < tl) return -1;
  if (l > tr) return -1;
  if (l <= tl && tr <= r) {
    int res = get(t[v], x, y);
    if (res == -1) return -1;
    return tl + res;
  }
  int mid = (tl + tr) >> 1;
  int ans1 = get(2 * v, tl, mid, l, r, x, y);
  int ans2 = get(2 * v + 1, mid + 1, tr, l, r, x, y);
  return max(ans1, ans2);
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    x--;
    g[x].push_back(i - 1);
    g[i - 1].push_back(x);
  }
  dfs(0, -1);
  build(1, 0, n - 1);
  while (q--) {
    int v;
    scanf("%d", &v);
    v--;
    if (cnt[v] == 1) {
      printf("%d\n", v + 1);
      continue;
    }
    int x = cnt[v] / 2;
    int y = (cnt[v] + 1) / 2;
    int res = get(1, 0, n - 1, L[v], R[v], x, y);
    assert(res != -1);
    printf("%d\n", order[res] + 1);
  }
  return 0;
}
