#include <bits/stdc++.h>
using namespace std;
const long long inf = 2147383647;
const long long mod = 1000000007;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
long long ext_gcd(long long A, long long B, long long* X, long long* Y) {
  long long x, y, u, v, m, n, a, b, q, r;
  x = 0;
  y = 1;
  u = 1;
  v = 0;
  for (a = A, b = B; 0 != a; b = a, a = r, x = u, y = v, u = m, v = n) {
    q = b / a;
    r = b % a;
    m = x - (u * q);
    n = y - (v * q);
  }
  *X = x;
  *Y = y;
  return b;
}
inline long long modInv(long long a, long long m) {
  long long x, y;
  ext_gcd(a, m, &x, &y);
  if (x < 0) x += m;
  return x;
}
inline long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1 % m, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
int n, q, uu;
int p[300005], st[300005], en[300005], sz[300005];
int cc, heavy[300005], chen[300005], label[300005];
vector<int> v[300005];
void dfs(int pos, int par) {
  p[pos] = par;
  sz[pos] = 1;
  heavy[pos] = -1;
  for (int i = 0; i < v[pos].size(); i++) {
    int j = v[pos][i];
    if (j == par) continue;
    dfs(j, pos);
    sz[pos] += sz[j];
    if (heavy[pos] == -1 || sz[heavy[pos]] < sz[j]) heavy[pos] = j;
  }
  return;
}
int rec(int pos, int par) {
  cc++;
  st[pos] = cc;
  label[cc] = pos;
  chen[pos] = st[pos];
  if (heavy[pos] == -1) return chen[pos];
  chen[pos] = rec(heavy[pos], pos);
  for (int i = 0; i < v[pos].size(); i++) {
    int j = v[pos][i];
    if (j == par) continue;
    if (j == heavy[pos]) continue;
    rec(j, pos);
  }
  en[pos] = cc;
  return chen[pos];
}
int main() {
  scanf("%d", &n);
  scanf("%d", &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &p[i]);
    v[p[i]].push_back(i);
  }
  cc = 0;
  dfs(1, 0);
  rec(1, 0);
  while (q--) {
    scanf("%d", &uu);
    int hi, lo, mid, tot = sz[uu];
    lo = st[uu], hi = chen[uu];
    while (hi >= lo) {
      mid = (hi + lo) / 2;
      int kk = label[mid];
      if (sz[kk] + sz[kk] < tot) {
        hi = mid - 1;
      } else {
        lo = mid + 1;
      }
    }
    printf("%d\n", label[hi]);
  }
  return 0;
}
