#include <bits/stdc++.h>
const int yuzu = 3e5;
typedef int fuko[yuzu | 10];
std::vector<int> lj[yuzu | 10];
fuko sz, ans, fa;
void dfs(int u) {
  sz[ans[u] = u] = 1;
  for (int i : lj[u]) dfs(i), sz[u] += sz[i];
  for (int i : lj[u]) sz[i] * 2 > sz[u] ? ans[u] = ans[i] : 0;
  for (; sz[ans[u]] * 2 < sz[u]; ans[u] = fa[ans[u]])
    ;
}
int main() {
  int i, n, q;
  std::cin >> n >> q;
  for (i = 2; i <= n; ++i) scanf("%d", fa + i), lj[fa[i]].push_back(i);
  for (dfs(1); q--; printf("%d\n", ans[i])) scanf("%d", &i);
}
