#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int stala = 1e6;
struct Graph {
  struct Ve {
    int s;
    int f;
    int centr;
    vector<int> ed;
  };
  vector<Ve> v;
  Graph(int n) { v.assign(n, Ve()); }
  void add(int from, int to) {
    v[from].ed.push_back(to);
    v[to].ed.push_back(from);
  }
  vector<int> order;
  int dfs(int act = 0, int f = -1) {
    v[act].s = 1;
    v[act].f = f;
    for (auto x : v[act].ed)
      if (x != f) v[act].s += dfs(x, act);
    order.push_back(act);
    return v[act].s;
  }
  void solve() {
    for (auto x : order) {
      bool s = 0;
      if (v[x].ed.size() > 1 || x == 0)
        for (auto y : v[x].ed)
          if (v[y].s > v[x].s / 2 && v[x].f != y) {
            s = 1;
            int centr;
            for (centr = v[y].centr; centr != x; centr = v[centr].f) {
              if (v[x].s - v[centr].s <= v[x].s / 2) break;
            }
            v[x].centr = centr;
            break;
          }
      if (!s) {
        v[x].centr = x;
      }
    }
  }
};
int n, q;
int32_t main() {
  ios::sync_with_stdio(0);
  cin >> n >> q;
  Graph g(n);
  for (int i = 0; i < n - 1; ++i) {
    int a;
    cin >> a;
    g.add(i + 1, a - 1);
  }
  g.dfs();
  g.solve();
  while (q--) {
    int a;
    cin >> a;
    cout << g.v[a - 1].centr + 1 << "\n";
  }
  return 0;
}
