
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define ll long long
#define FOR(i, s, f) for(ll (i) = (s); (i) < (f); (i)++)
const long long INF = 1e9;

vector<set<pair<ll, ll>>> graph;
vector<pair<ll, ll>> dp;

void DFS(ll x, set<pair<ll, ll>> &gr){
//    cout << x << endl;
//    for(auto it: gr){
//        cout << it.second << " ";
//    }
//    cout << '\n';
    if (gr.size() == 0) return;
    if (gr.size() == 1){
        ll g = (*gr.begin()).second;
        gr.erase(gr.begin());
        dp[g].first = min(dp[g].first, dp[x].first + 1);
        dp[g].second = min(dp[g].second, dp[x].second + 1);
        if (graph[g].size() > gr.size()){
            for(auto tt: gr){
                graph[g].insert(tt);
            }
            DFS(g, graph[g]);
            return;
        }
        for(auto tt: graph[x]){
            gr.insert(tt);
        }
        DFS(g, gr);
        return;

    }
    auto it = gr.end();
    it--;
    ll g = (*it).second;
    dp[g].first = min(dp[g].first, dp[x].first + 1);
    dp[g].second = min(dp[g].second, dp[x].second + 1);
    it--;
    ll t = (*it).second;
    dp[t].second = min(dp[t].second, dp[x].first + 1);
    it++;
    gr.erase(it);
    if (graph[g].size() > gr.size()){
        for(auto tt: gr){
            graph[g].insert(tt);
        }
        DFS(g, graph[g]);
        return;
    }
    for(auto tt: graph[g]){
        gr.insert(tt);
    }
    DFS(g, gr);
    return;
}

void solve(){
    ll n, q;
    cin >> n >> q;
    graph.resize(n);
    dp.resize(n, {INF, INF});
    dp[0] = {0, INF};
    vector<ll> pred(n - 1), comp(n);
    FOR(i, 0, n - 1) cin >> pred[i];
    FOR(i, 0, n) cin >> comp[i];
    FOR(i, 0, n - 1){
        graph[pred[i] - 1].insert({comp[i + 1], i + 1});
    }
    DFS(0, graph[0]);
//    FOR(i, 0, n){
//        cout << dp[i].first << " " << dp[i].second << '\n';
//    }
    while(q--){
        ll x;
        cin >> x;
        x--;
        cout << min(dp[x].first, dp[x].second) << " ";
    }
}

int main() {
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
