#include <bits/stdc++.h>
using namespace std;
const int OO = (int)2e9;
const int MOD = (int)1e9 + 7;
const long double Pi = 3.1415926535897932384626433832795;
const int N = (int)3e5 + 5;
int dp[N], mx[N], sz[N], p[N], n, q;
vector<int> g[N];
void dfs(int u) {
  int v;
  sz[u] = 1;
  mx[u] = 0;
  for (int i = (int)(0); i <= (int)((int)(g[u].size()) - 1); i++) {
    v = g[u][i];
    dfs(v);
    sz[u] += sz[v];
    if (sz[v] > sz[mx[u]]) mx[u] = v;
  }
  if (sz[mx[u]] <= sz[u] / 2)
    dp[u] = u;
  else {
    v = dp[mx[u]];
    while (sz[u] - sz[v] > sz[u] / 2) v = p[v];
    dp[u] = v;
  }
}
int main() {
  cin >> n >> q;
  for (int i = (int)(2); i <= (int)(n); i++) {
    scanf("%i", &p[i]);
    g[p[i]].push_back(i);
  }
  dfs(1);
  int x;
  while (q--) {
    cin >> x;
    printf("%i\n", dp[x]);
  }
}
