#include <bits/stdc++.h>
using namespace std;
const int maxn = 300050;
int n, q, f[maxn], son[maxn], fa[maxn], ans[maxn];
vector<int> nex[maxn];
bool isc(int v, int x) {
  return (son[v] - son[x]) * 2 <= son[v] && f[x] * 2 <= son[v];
}
void prepare(int x) {
  son[x] = 1;
  if (nex[x].size())
    for (int i = 0; i <= nex[x].size() - 1; ++i) {
      prepare(nex[x][i]);
      son[x] += son[nex[x][i]];
      f[x] = max(f[x], son[nex[x][i]]);
    }
}
void work(int x) {
  if (son[x] == 1) {
    ans[x] = x;
    return;
  }
  int c = 0, y;
  for (int i = 0; i <= nex[x].size() - 1; ++i) {
    y = nex[x][i];
    work(y);
    if (son[y] > son[c]) c = y;
  }
  c = ans[c];
  while (!isc(x, c)) c = fa[c];
  ans[x] = c;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; ++i) {
    int v;
    scanf("%d", &v);
    nex[v].push_back(i);
    fa[i] = v;
  }
  prepare(1);
  work(1);
  for (int i = 1; i <= q; ++i) {
    int v;
    scanf("%d", &v);
    printf("%d\n", ans[v]);
  }
  return 0;
}
