#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010;
int fa[maxn];
int num[maxn];
int ans[maxn];
vector<int> vec[maxn];
void dfs(int k) {
  num[k] = 1;
  ans[k] = k;
  for (int i = 0; i < vec[k].size(); ++i) {
    dfs(vec[k][i]);
    num[k] += num[vec[k][i]];
  }
  for (int i = 0; i < vec[k].size(); ++i) {
    if (num[vec[k][i]] * 2 > num[k]) {
      ans[k] = ans[vec[k][i]];
    }
  }
  while (num[k] > 2 * num[ans[k]]) {
    ans[k] = fa[ans[k]];
  }
}
int main() {
  int n, m, q;
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= n; ++i) {
    scanf("%d", &fa[i]);
    vec[fa[i]].push_back(i);
  }
  dfs(1);
  while (m--) {
    scanf("%d", &q);
    printf("%d\n", ans[q]);
  }
  return 0;
}
