#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> e[3000005];
int s[3000005], ans[3000005], fa[3000005];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
    if (ch == -1) return 0;
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void dfs(int u) {
  s[u] = 1, ans[u] = u;
  for (int v : e[u]) dfs(v), s[u] += s[v];
  for (int v : e[u])
    if ((s[v] << 1) > s[u]) ans[u] = ans[v];
  while ((s[u] - s[ans[u]]) * 2 > s[u]) ans[u] = fa[ans[u]];
}
int main() {
  n = read(), m = read();
  for (int i = 2; i <= n; i++) fa[i] = read(), e[fa[i]].push_back(i);
  dfs(1);
  while (m--) {
    int x;
    x = read(), printf("%d\n", ans[x]);
  }
  return 0;
}
