#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
ostream &operator<<(ostream &out, pair<T, T1> obj) {
  out << "(" << obj.first << ", " << obj.second << ")";
  return out;
}
template <typename T, typename T1>
ostream &operator<<(ostream &out, map<T, T1> cont) {
  typename map<T, T1>::const_iterator itr = cont.begin();
  typename map<T, T1>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, set<T> cont) {
  typename set<T>::const_iterator itr = cont.begin();
  typename set<T>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, multiset<T> cont) {
  typename multiset<T>::const_iterator itr = cont.begin();
  typename multiset<T>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T,
          template <typename ELEM, typename ALLOC = allocator<ELEM>> class CONT>
ostream &operator<<(ostream &out, CONT<T> cont) {
  typename CONT<T>::const_iterator itr = cont.begin();
  typename CONT<T>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T, unsigned int N, typename CTy, typename CTr>
typename enable_if<!is_same<T, char>::value, basic_ostream<CTy, CTr> &>::type
operator<<(basic_ostream<CTy, CTr> &out, const T (&arr)[N]) {
  for (auto i = 0; i < N; ++i) out << arr[i] << " ";
  out << endl;
  return out;
}
template <typename T>
T gcd(T a, T b) {
  T min_v = min(a, b);
  T max_v = max(a, b);
  while (min_v) {
    T temp = max_v % min_v;
    max_v = min_v;
    min_v = temp;
  }
  return max_v;
}
template <typename T>
T lcm(T a, T b) {
  return (a * b) / gcd(a, b);
}
template <typename T>
T fast_exp_pow(T base, T exp, T mod) {
  T res = 1;
  while (exp) {
    if (exp & 1) {
      res *= base;
      res %= mod;
    }
    exp >>= 1;
    base *= base;
    base %= mod;
  }
  return res % mod;
}
int N, Q, V;
int parent[300010], subTree[300010], centroid[300010], maxSub[300010],
    maxChild[300010];
vector<int> graph[300010];
void calcSubTree(int node) {
  subTree[node] = 1;
  for (auto connNode : graph[node]) {
    if (connNode != parent[node]) {
      calcSubTree(connNode);
      subTree[node] += subTree[connNode];
      if (maxSub[node] < subTree[connNode]) {
        maxSub[node] = subTree[connNode];
        maxChild[node] = connNode;
      }
    }
  }
}
int findCentr(int root, int node) {
  if (2 * maxSub[node] > subTree[root]) {
    return findCentr(root, maxChild[node]);
  }
  return node;
}
void dfs(int node, int centr) {
  int bigChild = -1, newCentr = findCentr(node, centr);
  centroid[node] = newCentr;
  if (newCentr != node) {
    dfs(maxChild[node], newCentr);
  }
  for (auto connNode : graph[node]) {
    if (connNode != parent[node] &&
        (connNode != maxChild[node] || newCentr == node)) {
      dfs(connNode, connNode);
    }
  }
}
int main() {
  scanf("%d%d", &N, &Q);
  for (auto i = 2; i <= N; ++i) {
    scanf("%d", parent + i);
    graph[i].push_back(parent[i]);
    graph[parent[i]].push_back(i);
  }
  calcSubTree(1);
  dfs(1, 1);
  while (Q--) {
    scanf("%d", &V);
    printf("%d\n", centroid[V]);
  }
  return 0;
}
