#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
mt19937 rnd(time(NULL));
vector<vector<int>>graph;
vector<int>c; int cnt = 0; int l;
set<pair<int, int>>del; vector<int>num;
int ans(int start){
    if(l == start) return cnt;
    num[start] = cnt;
    pair<int, int>val = {-1, -1};
    for(auto v: graph[start]){
        if(val.first < c[v]){
            val.first = c[v]; val.second = v;
        }
    }
    if(!del.empty()) val = max(val, *(--del.end()));
    for(auto v: graph[start]) del.insert({c[v], v});
    del.erase(val); cnt++; return ans(val.second);
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q; cin >> n >> q; num.resize(n);
    vector<int>p(n); graph.resize(n); c.resize(n);
    for(int i = 0; i < n - 1; i++){
        cin >> p[i]; graph[p[i] - 1].push_back(i + 1);
    }
    for(int i = 0; i < n; i++) cin >> c[i];
    while(q--){
        int v; cin >> v; v--; int mx = 1e9; l = v;
        for(int i = 0; i < n; i++){
            int val = c[i]; c[i] = 0; cnt = 0; mx = min(mx, ans(0)); c[i] = val;
        }
        cout << mx << " ";
    }
    return 0;
}