#include <bits/stdc++.h>
using namespace std;
vector<int> tr[300005];
int sz[300005];
int cen[300005];
int p[20][300005];
int dfs(int i) {
  sz[i] = 1;
  int mx = 0;
  int mxi = -1;
  for (int j = 0; j < tr[i].size(); j++) {
    int r = dfs(tr[i][j]);
    sz[i] += r;
    if (r > mx) {
      mx = r;
      mxi = tr[i][j];
    }
  }
  p[0][i] = mxi;
  for (int j = 1; j < 20; j++) {
    if (p[j - 1][i] == -1) break;
    p[j][i] = p[j - 1][p[j - 1][i]];
  }
  int cur = i;
  for (int j = 19; j >= 0; j--) {
    if (p[j][cur] == -1) continue;
    if (sz[p[j][cur]] * 2 > sz[i]) cur = p[j][cur];
  }
  cen[i] = cur;
  return sz[i];
}
void init() {
  memset(sz, 0, sizeof(sz));
  memset(p, -1, sizeof(p));
  memset(cen, -1, sizeof(cen));
  dfs(0);
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d", &u);
    u--;
    tr[u].push_back(i);
  }
  init();
  for (int i = 0; i < q; i++) {
    int x;
    scanf("%d", &x);
    x--;
    printf("%d\n", cen[x] + 1);
  }
}
