#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& _p) {
  return os << "(" << _p.first << "," << _p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& _V) {
  bool f = true;
  os << "[";
  for (auto v : _V) {
    os << (f ? "" : ",") << v;
    f = false;
  }
  return os << "]";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& _S) {
  bool f = true;
  os << "(";
  for (auto s : _S) {
    os << (f ? "" : ",") << s;
    f = false;
  }
  return os << ")";
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& _M) {
  return os << set<pair<T, U>>(_M.begin(), _M.end());
}
const signed long long INF = 1000000100;
const long double EPS = 1e-9;
const int MAXN = 300100;
vector<int> G[MAXN];
int N, Q;
int query[MAXN];
void read_data() {
  scanf("%d %d", &N, &Q);
  for (int(i) = (2); (i) <= (N); (i)++) {
    int t;
    scanf("%d", &t);
    G[t].push_back(i);
  }
  for (int(i) = (1); (i) <= (N); (i)++) scanf("%d", query + i);
}
int S[MAXN];
int P[MAXN];
void dfs1(int v) {
  S[v] = 1;
  for (int u : G[v]) {
    dfs1(u);
    S[v] += S[u];
    P[u] = v;
  }
}
int R[MAXN];
void dfs2(int v, int w) {
  if (S[v] == 1) {
    R[v] = v;
    return;
  }
  if (w == -1) w = v;
  if (P[v] == w) w = v;
  while (S[G[w].front()] > S[v] / 2) {
    w = G[w].front();
  }
  R[v] = w;
  dfs2(G[v].front(), w);
  for (int(i) = (1); (i) < (int(G[v].size())); (i)++) dfs2(G[v][i], -1);
}
void solve() {
  dfs1(1);
  for (int(v) = (1); (v) <= (N); (v)++)
    sort(G[v].begin(), G[v].end(), [](int a, int b) { return S[a] > S[b]; });
  dfs2(1, -1);
  for (int(i) = (1); (i) <= (Q); (i)++) printf("%d\n", R[query[i]]);
}
int main() {
  read_data();
  solve();
}
