#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const int N = 300005;
int p[N], sum[N], dp[N];
vector<int> g[N];
bool cmp(int q, int w) { return (sum[q] > sum[w]); }
void dfs(int v, int pr = 0) {
  p[v] = pr;
  sum[v] = 1;
  if (pr && g[v].size() == 1) {
    dp[v] = v;
    return;
  }
  vector<int> a;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to == pr) continue;
    dfs(to, v);
    a.push_back(to);
    sum[v] += sum[to];
  }
  sort((a).begin(), (a).end(), cmp);
  int n = a.size();
  int first = dp[a[0]];
  while (sum[v] - sum[first] > sum[v] / 2) {
    first = p[first];
  }
  dp[v] = first;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 2; i <= n; i++) {
    int first;
    cin >> first;
    g[i].push_back(first);
    g[first].push_back(i);
  }
  dfs(1);
  for (int i = 1; i <= m; i++) {
    int first;
    cin >> first;
    cout << dp[first] << "\n";
  }
}
