#include <bits/stdc++.h>
using namespace std;
const int N = 300020;
int n, q;
int ans[N], son[N], fa[N];
vector<int> ve[N];
void dfs(int u) {
  son[u] = 1;
  ans[u] = u;
  for (int i = 0; i < ve[u].size(); i++) {
    int v = ve[u][i];
    dfs(v);
    son[u] += son[v];
  }
  for (int i = 0; i < ve[u].size(); i++) {
    if (son[ve[u][i]] * 2 > son[u]) {
      ans[u] = ans[ve[u][i]];
    }
  }
  while ((son[u] - son[ans[u]]) * 2 > son[u]) ans[u] = fa[ans[u]];
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &fa[i]);
    ve[fa[i]].push_back(i);
  }
  dfs(1);
  for (int i = 1; i <= q; i++) {
    int x;
    scanf("%d", &x);
    printf("%d\n", ans[x]);
  }
  return 0;
}
