#include <bits/stdc++.h>
using namespace std;
int n, k, subt[300010], big_chi[300010], ans[300010], _timer = 0, pos[300010];
vector<int> grp[300010];
void DFS(int ver) {
  pos[++_timer] = ver;
  int mx = 0;
  subt[ver] = 1;
  for (int v : grp[ver]) {
    DFS(v);
    if (subt[v] > mx) {
      mx = subt[v];
      big_chi[ver] = v;
    }
    subt[ver] += subt[v];
  }
}
int do_st(int num, int v) {
  if (subt[big_chi[v]] <= num) {
    return v;
  }
  int ans = do_st(num, big_chi[v]);
  big_chi[v] = ans;
  return ans;
}
int query(int ver) { return do_st(subt[ver] / 2, ver); }
int main() {
  cin >> n >> k;
  int v;
  for (int i = 2; i <= n; i++) {
    cin >> v;
    grp[v].push_back(i);
  }
  DFS(1);
  for (int i = 1; i <= n; i++) {
    ans[pos[i]] = query(pos[i]);
  }
  for (int i = 1; i <= k; i++) {
    cin >> v;
    cout << ans[v] << "\n";
  }
}
