#include <bits/stdc++.h>
using namespace std;
const int mxn = 300010;
int f[mxn], d[mxn], w[mxn], z[mxn], n, q;
vector<int> g[mxn];
void dfs1(int x) {
  d[x] = 1;
  int i, sz = g[x].size();
  if (sz == 0) return;
  for (i = 0; i < sz; i++) dfs1(g[x][i]);
  int mx = 0, y = 0;
  for (i = 0; i < sz; i++) {
    int j = g[x][i];
    d[x] += d[j];
    if (d[j] > mx) {
      mx = d[j];
      y = j;
    }
  }
  w[x] = y;
}
void dfs(int x) {
  int i, sz = g[x].size();
  if (sz == 0) {
    z[x] = x;
    return;
  }
  for (i = 0; i < sz; i++) dfs(g[x][i]);
  int y = z[w[x]];
  for (;;) {
    if (y == x || d[w[f[y]]] >= d[x] - d[y]) break;
    y = f[y];
  }
  z[x] = y;
}
int main() {
  int i, x;
  scanf("%d%d", &n, &q);
  for (i = 2; i <= n; i++) {
    scanf("%d", &f[i]);
    g[f[i]].push_back(i);
  }
  dfs1(1);
  dfs(1);
  for (i = 0; i < q; i++) {
    scanf("%d", &x);
    printf("%d\n", z[x]);
  }
  return 0;
}
