#ifndef LOCAL
  #pragma GCC optimize("Ofast,unroll-loops")
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef LOCAL
  #pragma GCC target("avx,avx2,fma")
#endif

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

const int maxn = 3e5 + 1;

vector<int> g[maxn];
int p[maxn], tin[maxn], tout[maxn], s[maxn], ans[maxn], cnt[maxn];
int n, q;
int tt = 0;

void dfs(int u = 1) {
  tin[u] = tt++;
  for (int v : g[u]) {
    dfs(v);
  }
  tout[u] = tt;
}

bool is_par(int u, int v) {
  return tin[u] <= tin[v] && tout[v] <= tout[u];
}

void solve() {
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    cin >> p[i];
    g[p[i]].push_back(i);
  }
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
  }
  dfs();
  vector<int> h;
  set<pair<int, int>, greater<>> val;
  val.emplace(s[1], 1);
  while (!val.empty()) {
    int u = val.begin()->second;
    h.push_back(u);
    val.erase(val.begin());
    for (int v : g[u]) {
      val.emplace(s[v], v);
    }
  }
  set<pair<int, int>, greater<>> mx;
  mx.emplace(0, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = h[i], c = 0; j; ++c, j = p[j]) {
      mx.erase({cnt[j], j});
      assert(c <= 100);
    }
    ans[h[i]] = i - mx.begin()->first;
    for (int j = h[i], c = 0; j; ++c, j = p[j]) {
      mx.insert({++cnt[j], j});
      assert(c <= 100);
    }
  }
  for (int i = 0; i < q; ++i) {
    int u;
    cin >> u;
    cout << ans[u] << ' ';
  }
  cout << '\n';
}

signed main() {
  cin.tie(0)->sync_with_stdio(0);
  int t = 1;
  // cin >> t;
  for (int i = 0; i < t; ++i) {
    solve();
  }
}