#include <bits/stdc++.h>
using namespace std;
int n;
int maxParents = 0;
const int maxN = 300000;
int sum[maxN];
int ans[maxN];
int h[maxN];
int maxChildId[maxN];
vector<vector<int>> childs;
vector<vector<int>> parents;
int calcSum(int v) {
  int ans = 1;
  for (int child : childs[v]) {
    ans += calcSum(child);
  }
  sum[v] = ans;
  return ans;
}
int calcH(int v) {
  if (h[v] == -1) {
    h[v] = calcH(parents[v][0]) + 1;
  }
  return h[v];
}
void calcMax() {
  for (int i = 0; i < n; i++) {
    int bestSum = -1;
    for (int child : childs[i]) {
      if (sum[child] > bestSum) {
        bestSum = sum[child];
        maxChildId[i] = child;
      }
    }
  }
}
int calcAns(int v) {
  int& res = ans[v];
  if (res != -1) {
    return res;
  }
  int maxSize = sum[v] / 2;
  int child = maxChildId[v];
  if (child == -1 || sum[child] <= maxSize) {
    res = v;
    return res;
  }
  int nextChild = calcAns(child);
  while (true) {
    if (h[v] >= h[nextChild]) {
      cout << "Bad: " << v << " " << nextChild << endl;
      return res;
    }
    if (sum[v] - sum[nextChild] <= maxSize) {
      res = nextChild;
      return res;
    }
    int a = 0;
    int b = maxParents;
    while (a < b - 1) {
      int m = (a + b) / 2;
      int testV = parents[nextChild][m];
      if (testV == -1 || h[testV] <= h[v]) {
        b = m;
        continue;
      }
      if (sum[v] - sum[testV] > maxSize) {
        a = m;
      } else {
        b = m;
      }
    }
    nextChild = parents[nextChild][a];
  }
}
void calcParents() {
  for (int i = 0; i < n; i++) {
    for (int p = 1; p < maxParents; p++) {
      int predP = parents[i][p - 1];
      parents[i][p] = predP != -1 ? parents[predP][p] : -1;
    }
  }
}
int main() {
  cin.sync_with_stdio(0);
  int q;
  cin >> n >> q;
  int nCopy = n;
  while (nCopy > 0) {
    maxParents++;
    nCopy = nCopy / 2;
  }
  childs.resize(n);
  parents.resize(n);
  for (int i = 0; i < n; i++) {
    sum[i] = -1;
    ans[i] = -1;
    h[i] = -1;
    maxChildId[i] = -1;
    parents[i].resize(maxParents);
    parents[i][0] = -1;
  }
  h[0] = 0;
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    p--;
    parents[i].resize(maxParents);
    parents[i][0] = p;
    childs[p].push_back(i);
  }
  calcSum(0);
  calcMax();
  for (int i = 0; i < n; i++) {
    calcH(i);
  }
  for (int i = 0; i < q; i++) {
    int request;
    cin >> request;
    request--;
    cout << calcAns(request) + 1 << endl;
  }
  return 0;
}
