#include <bits/stdc++.h>
using namespace std;
int pred[300005];
int dfs(vector<list<int> >& listeAdj, vector<int>& tailleSubtree, int pos,
        vector<int>& plusGrandSubtreeFils) {
  list<int>::iterator it;
  int sum = 0;
  plusGrandSubtreeFils[pos] = 0;
  if (listeAdj[pos].size() == 0) {
    tailleSubtree[pos] = 1;
    return 1;
  }
  for (it = listeAdj[pos].begin(); it != listeAdj[pos].end(); it++) {
    int fils = dfs(listeAdj, tailleSubtree, *it, plusGrandSubtreeFils);
    sum += fils;
    plusGrandSubtreeFils[pos] = max(plusGrandSubtreeFils[pos], fils);
  }
  tailleSubtree[pos] = sum + 1;
  return sum + 1;
}
bool estCentroid(int pos, int cur, vector<int>& tailleSubtree,
                 vector<int>& plusGrandSubtreeFils) {
  return (tailleSubtree[pos] - tailleSubtree[cur]) * 2 <= tailleSubtree[pos] &&
         plusGrandSubtreeFils[cur] * 2 <= tailleSubtree[pos];
}
void recherche(vector<list<int> >& listeAdj, vector<int>& tailleSubtree,
               int pos, vector<int>& centroid,
               vector<int>& plusGrandSubtreeFils) {
  if (tailleSubtree[pos] == 1) {
    centroid[pos] = pos;
  } else {
    list<int>::iterator it;
    int iMax = *listeAdj[pos].begin();
    for (it = listeAdj[pos].begin(); it != listeAdj[pos].end(); it++) {
      recherche(listeAdj, tailleSubtree, *it, centroid, plusGrandSubtreeFils);
      if (tailleSubtree[iMax] < tailleSubtree[*it]) iMax = *it;
    }
    int cur = centroid[iMax];
    while (!estCentroid(pos, cur, tailleSubtree, plusGrandSubtreeFils)) {
      cur = pred[cur];
    }
    centroid[pos] = cur;
  }
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  vector<list<int> > listeAdj(n);
  vector<int> tailleSubtree(n);
  vector<int> plusGrandSubtreeFils(n);
  for (int i = 1; i < n; i++) {
    int a;
    scanf("%d", &a);
    a--;
    pred[i] = a;
    listeAdj[a].push_back(i);
  }
  dfs(listeAdj, tailleSubtree, 0, plusGrandSubtreeFils);
  vector<int> centroid(n);
  recherche(listeAdj, tailleSubtree, 0, centroid, plusGrandSubtreeFils);
  for (int i = 0; i < q; i++) {
    int a;
    scanf("%d", &a);
    a--;
    printf("%d\n", 1 + centroid[a]);
  }
}
