#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long inv(long long i) {
  if (i == 1) return 1;
  return (mod - ((mod / i) * inv(mod % i)) % mod) % mod;
}
long long mod_mul(long long a, long long b) {
  a = a % mod;
  b = b % mod;
  return (((a * b) % mod) + mod) % mod;
}
long long mod_add(long long a, long long b) {
  a = a % mod;
  b = b % mod;
  return (((a + b) % mod) + mod) % mod;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long ceil_div(long long a, long long b) {
  return a % b == 0 ? a / b : a / b + 1;
}
long long pwr(long long a, long long b) {
  a %= mod;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
vector<vector<long long> > adj;
vector<long long> parent;
vector<long long> centroid;
vector<long long> sz;
vector<long long> worst_node;
void dfs(long long curr_node) {
  sz[curr_node] = 1;
  worst_node[curr_node] = 0;
  for (auto x : adj[curr_node]) {
    dfs(x);
    sz[curr_node] += sz[x];
    if (sz[x] >= sz[worst_node[curr_node]]) worst_node[curr_node] = x;
  }
  if (sz[worst_node[curr_node]] <= sz[curr_node] / 2) {
    centroid[curr_node] = curr_node;
    return;
  }
  long long curr = centroid[worst_node[curr_node]];
  while (1) {
    long long above = sz[curr_node] - sz[curr];
    long long below = sz[worst_node[curr]];
    if (max(above, below) <= sz[curr_node] / 2) {
      centroid[curr_node] = curr;
      break;
    }
    curr = parent[curr];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, n, i, j, ans, temp, sum, q, x;
  string sans;
  t = 1;
  while (t--) {
    sans = "NO";
    ans = temp = sum = 0;
    cin >> n >> q;
    adj.assign(n + 1, {});
    centroid.assign(n + 1, 0);
    parent.assign(n + 1, 0);
    sz.assign(n + 1, 0);
    worst_node.assign(n + 1, 0);
    for (i = 2; i <= n; i++) {
      cin >> x;
      adj[x].push_back(i);
      parent[i] = x;
    }
    dfs(1);
    for (i = 1; i <= q; i++) {
      cin >> x;
      cout << centroid[x] << "\n";
    }
  }
  return 0;
}
