#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;

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 dfs(ll v, ll pr){
    prr[v] = pr;
    for(auto u : G[v]){
        dfs(u, pr);
    }
}

void solve(){
    ll n, q;
    std::cin >> n >> q;
    p.resize(n);
    s.resize(n);
    G.resize(n);
    prr.resize(n, -1);
    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();
    ll c = 0;
    while (G[c].size() == 1){
        c = G[c][0];
    }
    for(auto u : G[c]){
        dfs(u, u);
    }
    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;
        if (prr[v] == -1){
            std::cout << obh[v] <<' ';
            continue;
        }
        std::vector<ll> cnt(n);
        ll mx = 0;
        for (int j = 0; j < ord[v]; ++j) {
            if (prr[obh[j]] == -1) continue;
            ++cnt[prr[obh[j]]];
            if (prr[obh[j]] != prr[v]){
                mx = std::max(mx, cnt[prr[obh[j]]]);
            }
        }
        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();
    }
}
