#include <bits/stdc++.h>
using namespace std;
long long int i, j, p, d, n, m, total, k, ok, a, b, c, op, maxi, rasp, m1, m2,
    p1, p2, rez, modu = 1000000007, mini, mij, ls, ld;
int nod[300005], marime[300005], tata[300005];
vector<int> v[300005];
void dfs(int x) {
  for (int i = 0; i < v[x].size(); i++) {
    dfs(v[x][i]);
    marime[x] += marime[v[x][i]];
  }
  marime[x]++;
  for (i = 0; i < v[x].size(); i++) {
    if (marime[v[x][i]] >= (marime[x] + 1) / 2) {
      nod[x] = nod[v[x][i]];
      break;
    }
  }
  if (nod[x] == 0)
    nod[x] = x;
  else
    while (marime[nod[x]] < (marime[x] + 1) / 2) nod[x] = tata[nod[x]];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (i = 2; i <= n; i++) cin >> a, tata[i] = a, v[a].push_back(i);
  dfs(1);
  for (i = 1; i <= m; i++) cin >> a, cout << nod[a] << '\n';
  return 0;
}
