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

#pragma GCC optimize("O3")

using namespace std;
//using namespace __gnu_pbds;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

//#define int long long

//typedef tree<int, null_type,less<int>,  rb_tree_tag, tree_order_statistics_node_update> ordered_set;


signed main(){
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
    int n, q;
    cin>>n>>q;
    vector<vector<int> > g(n);
    vector<int> pr(n, -1);
    for(int i = 1; i < n; ++i){
        int p; cin>>p;
        --p;
        g[p].push_back(i);
        g[i].push_back(p);
        pr[i] = p;
    }
    vector<int> s(n);
    for(auto &x:s) cin>>x;
    priority_queue<pair<int,int>, vector<pair<int,int> >, less<pair<int,int> > > qq;
    vector<int> used(n);
    auto calc = [&](int ban, int vq) -> int{
        used.assign(n, 0);
        qq.emplace(s[0], 0);
        int old = s[ban];
        s[ban] = 0;
        int j = 0;
        used[0] = 1;
        int pos = n;
        while(!qq.empty()){
            auto [val, v ] = qq.top();
            qq.pop();
            if (v == vq){
                pos=j;
                break;
            }
            ++j;
            for(int u:g[v]){
                if (!used[u]){
                    qq.emplace(s[u], u);
                    used[u] = 1;
                }
            }
        }
        s[ban] = old;
        return pos;
    };
    while(q--){
        int v;
        cin>>v; --v;
        int res = n;
        for(int ban = 0; ban < n; ++ban){
            res = min(res, calc(ban, v));
        }
        cout<<res<<' ';
    }
    return 0;
}
