#include <bits/stdc++.h>
using namespace std;
template <class T>
bool remin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool remax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int nxt() {
  int first;
  scanf("%d", &first);
  return first;
}
long long gcd(long long a, long long b) {
  a = abs(a);
  b = abs(b);
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
struct pt {
  long double first, second, z;
  pt() {}
  pt(long double first, long double second, long double z)
      : first(first), second(second), z(z) {}
  inline pt operator-(const pt &r) const {
    return pt(first - r.first, second - r.second, z - r.z);
  }
  inline pt operator+(const pt &r) const {
    return pt(first + r.first, second + r.second, z + r.z);
  }
  inline pt operator*(const long double &r) const {
    return pt(first * r, second * r, z * r);
  }
  inline long double sqlen() const {
    return abs(first * first + second * second + z * z);
  }
  long double len() const { return sqrtl(sqlen()); }
  inline bool operator<(const pt &r) const {
    if (first != r.first) return first < r.first;
    return second < r.second;
  }
  inline bool operator==(const pt &r) const {
    return first == r.first && second == r.second;
  }
};
ostream &operator<<(ostream &os, const pt &p) {
  return os << "(" << p.first << "," << p.second << ")";
}
inline pt cross(const pt &l, const pt &r) {
  return pt(l.second * r.z - l.z * r.second, l.z * r.first - l.first * r.z,
            l.first * r.second - l.second * r.first);
}
inline long double dot(const pt &l, const pt &r) {
  return l.first * r.first + l.second * r.second + l.z * r.z;
}
long long pwmod(long long a, long long n, long long mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) ret = ret * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return ret;
}
template <typename T>
inline T sqr(T first) {
  return first * first;
}
bool remin(long long &first, long long second) {
  if (first > second) {
    first = second;
    return 1;
  }
  return 0;
}
const int N = 300 * 1000;
vector<int> g[N];
int size[N];
int parent[N];
int answer[N];
int maxSize[N];
vector<int> childs_[N];
void dfs(int v, int p = -1) {
  size[v] = 1;
  parent[v] = p;
  for (int to : g[v]) {
    if (to == p) continue;
    dfs(to, v);
    size[v] += size[to];
  }
  maxSize[v] = 0;
  for (int to : g[v]) {
    if (to == p) continue;
    remax(maxSize[v], size[to]);
  }
}
void dfs2(int v, int p = -1) {
  vector<int> &ch = childs_[v];
  for (int to : g[v]) {
    if (to == p) continue;
    dfs2(to, v);
    ch.push_back(answer[to]);
  }
  if (ch.empty()) {
    answer[v] = v;
    return;
  }
  for (int &u : ch) {
    int s = size[v] / 2;
    while (u != v && maxSize[parent[u]] <= s) {
      u = parent[u];
    }
  }
  for (int u : ch) {
    int s = size[v] / 2;
    int top = size[v] - size[u];
    if (maxSize[u] <= s && top <= s) {
      answer[v] = u;
    }
  }
}
void solve() {
  int n = nxt();
  int q = nxt();
  for (int i = 1; i < n; ++i) {
    int p = nxt() - 1;
    g[p].push_back(i);
    g[i].push_back(p);
  }
  dfs(0);
  dfs2(0);
  for (int i = 0; i < (int)(q); i++) {
    int v = nxt() - 1;
    cout << answer[v] + 1 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  for (int i = 0; i < (int)(t); i++) {
    solve();
  }
  return 0;
}
