#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifndef DEBUG
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
#endif

using namespace __gnu_pbds;

template <typename T>
using oset = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using pll = std::pair<ll, ll>;
using ld = long double;
using i128 = __int128;

std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());

std::vector<ll> p, s;
std::vector<std::vector<ll>> G;
std::vector<ll> obh;
std::vector<ll> prr;
std::vector<ll> tin, tout, depth;
ll timer = 0;

void bfs(){
    std::priority_queue<pll, std::vector<pll>> g;
    g.push({s[0], 0});
    while (!g.empty()){
        auto [el, v] = g.top();
        g.pop();
        obh.push_back(v);
        for(auto u : G[v]){
            g.push({s[u], u});
        }
    }
}

void dfs1(ll v, ll dep = 0){
    tin[v] = timer++;
    depth[v] = dep;
    for(auto u : G[v]){
        dfs1(u, dep + 1);
    }
    tout[v] = timer++;
}

bool isAnc(ll v, ll u){
    if (tin[v] <= tin[u] && tout[u] <= tout[v]){
        return true;
    }
    return false;
} // v -> u

void solve(){
    ll n, q;
    std::cin >> n >> q;
    p.resize(n, -1);
    s.resize(n);
    G.resize(n);
    tin.resize(n);
    tout.resize(n);
    depth.resize(n);
    for (int i = 1; i < n; ++i) {
        std::cin >> p[i];
        --p[i];
        G[p[i]].push_back(i);
    }
    for (int i = 0; i < n; ++i) {
        std::cin >> s[i];
    }
    bfs();
    dfs1(0);
    std::vector<ll> ord(n);
    for (int i = 0; i < n; ++i) {
        ord[obh[i]] = i;
    }
    for (int i = 0; i < q; ++i) {
        ll v;
        std::cin >> v;
        --v;

        std::vector<ll> cnt(n);
        ll mx = 0;
        for (int j = 0; j < ord[v]; ++j) {
            ll u = obh[j];
            while (u != -1){
                ++cnt[u];
                u = p[u];
            }
        }
        for (int j = 0; j < n; ++j) {
            if (isAnc(j, v)){
                cnt[j] -= 1e9;
            }
        }
        mx = std::max(mx, *std::max_element(cnt.begin(), cnt.end()));
        std::cout << ord[v] - mx <<' ';
    }
}

int main() {
#ifdef DEBUG
    std::freopen("/home/olymp/CLionProjects/untitled/input.txt", "r", stdin);
#endif
    std::cin.tie(0) -> std::ios::sync_with_stdio(0);
    int tt = 1;
//    std::cin >> tt;
    while (tt--){
        solve();
    }
}
