#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int centroid[300005], A[300005], P[300005], sub[300005];
bool taken[300005];
vector<vector<int> > adj;
int assign_centroid(int x, int v) {
  while (2 * sub[x] < sub[v] && P[x] != x) {
    x = P[x];
  }
  return x;
}
int dfs(int v) {
  int child = 1;
  bool entered = false;
  int Max = -1, kid;
  taken[v] = true;
  for (auto it : adj[v])
    if (!taken[it]) {
      kid = dfs(it);
      child += kid;
      if (kid > Max) {
        Max = kid;
        A[v] = it;
      }
      entered = true;
    }
  sub[v] = child;
  if (!entered) {
    centroid[v] = v;
    A[v] = v;
  } else
    centroid[v] = assign_centroid(centroid[A[v]], v);
  return sub[v];
}
int main() {
  int n, q;
  int i;
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> q;
  adj.resize(n + 1);
  for (i = 2; i < n + 1; i++) {
    cin >> P[i];
    adj[i].push_back(P[i]);
    adj[P[i]].push_back(i);
  }
  P[1] = 1;
  dfs(1);
  int x;
  while (q--) {
    cin >> x;
    cout << centroid[x] << endl;
  }
  return 0;
}
