#include <bits/stdc++.h>
using namespace std;
int size[300005], cen[300005], fa[300005];
vector<int> son[300005];
void dfs(int x) {
  vector<int>::iterator it;
  cen[x] = x;
  size[x] = 1;
  for (it = son[x].begin(); it != son[x].end(); ++it)
    dfs(*it), size[x] += size[*it];
  for (it = son[x].begin(); it != son[x].end(); ++it)
    if (size[*it] * 2 > size[x]) cen[x] = cen[*it];
  while ((size[x] - size[cen[x]]) * 2 > size[x]) cen[x] = fa[cen[x]];
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  fa[1] = 1;
  for (int i = 2; i <= n; ++i) {
    scanf("%d", &fa[i]);
    son[fa[i]].push_back(i);
  }
  dfs(1);
  for (int i = 1; i <= q; ++i) {
    int qu;
    scanf("%d", &qu);
    printf("%d\n", cen[qu]);
  }
  return 0;
}
