
#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<ll> ans;
ll tt = 0;

void DFS(ll x, set<pair<ll, ll>> &gr){
    ans[x] = min(ans[x], tt++);
    if (gr.size() == 0) return;
    auto it = gr.end();
    it--;
    ll g = (*it).second;
    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);
    ans.resize(n, 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){
        tt = 0;
        ll t = comp[i];
        comp[i] = 0;
        graph.clear();
        graph.resize(n);
        FOR(j, 0, n - 1){
            graph[pred[j] - 1].insert({comp[j + 1], j + 1});
        }
        DFS(0, graph[0]);
        comp[i] = t;
    }
    while(q--){
        ll x;
        cin >> x;
        x--;
        cout << ans[x] << " ";
    }
}

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