#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 1;
int n, q, p[N], sz[N], c[N], u;
vector<int> g[N];
void slv(int u) {
  sz[u] = 1;
  int ls = 0;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    slv(g[u][i]);
    sz[u] += sz[v];
    if (sz[v] > sz[ls]) ls = v;
  }
  c[u] = u;
  if (sz[ls] > sz[u] / 2) {
    c[u] = c[ls];
    while (sz[u] - sz[c[u]] > sz[u] / 2) c[u] = p[c[u]];
  }
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 2; i <= n; ++i) scanf("%d", p + i), g[p[i]].push_back(i);
  slv(1);
  for (int i = 0; i < q; ++i) scanf("%d", &u), printf("%d\n", c[u]);
  return 0;
}
