#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const long long mod = 998244353;
const long long INF = 0x3f3f3f3f;
const double eps = 1e-8;
inline long long read() {
  long long ans = 0, flag = 1;
  char c;
  c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + (long long)(c - '0');
    c = getchar();
  }
  return ans * flag;
}
long long quickpow(long long x, long long y, long long mod) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = ans * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
vector<int> G[maxn];
int fa[maxn];
int num[maxn];
bool vis[maxn];
int ans[maxn];
int dfs1(int x) {
  vis[x] = true;
  for (int i = 0; i < G[x].size(); i++) {
    int v = G[x][i];
    if (!vis[v]) num[x] += dfs1(v);
  }
  num[x]++;
  return num[x];
}
void dfs2(int x) {
  vis[x] = true;
  int temp = 0, pos;
  if (G[x].size() == 0) {
    ans[x] = x;
    return;
  }
  for (int i = 0; i < G[x].size(); i++) {
    int v = G[x][i];
    if (!vis[v]) dfs2(v);
    if (num[v] > temp) {
      temp = num[v];
      pos = ans[v];
    }
  }
  while (pos != x) {
    if (num[x] - num[pos] <= num[x] / 2) {
      ans[x] = pos;
      break;
    }
    pos = fa[pos];
  }
  ans[x] = pos;
}
int main() {
  int n, q;
  while (cin >> n >> q) {
    memset(fa, -1, sizeof fa);
    for (int i = 2; i <= n; i++) {
      int x;
      x = read();
      fa[i] = x;
      G[x].push_back(i);
    }
    memset(num, 0, sizeof num);
    int pos;
    for (int i = 1; i <= n; i++) {
      if (fa[i] == -1) {
        pos = i;
        break;
      }
    }
    memset(vis, false, sizeof vis);
    dfs1(pos);
    memset(vis, false, sizeof vis);
    dfs2(pos);
    while (q--) {
      int x;
      x = read();
      cout << ans[x] << endl;
    }
  }
  return 0;
}
