#include "bits/stdc++.h"
using namespace std;
# define int long long
# define all(a) a.begin(), a.end()


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    vector<int> pred(n, -1);
    for(int i = 1; i < n; ++i){
        int p;
        cin >> p;
        --p;
        pred[i] = p;
        g[p].push_back(i);
    }
    vector<int> s(n);
    for(auto &i : s) cin >> i;
//    dfs(dfs, 0);
    auto check = [&](int v, vector<vector<int>> &cur_g) ->int{
        int root = 0;
//        auto cur_g = g;
        int cnt = 0;
        while(v != root){
            int best = 0;
            for(int i = 0; i < cur_g[root].size(); ++i){
                if(s[cur_g[root][i]] > s[cur_g[root][best]]){
                    best = i;
                }
            }
            int n_root = cur_g[root][best];
            cur_g[n_root].insert(cur_g[n_root].end(), all(cur_g[root]));
            cur_g[n_root].erase(find(all(cur_g[n_root]), n_root));
            root = n_root;
            ++cnt;
        }
        return cnt;
    };
    while(q--){
        int v;
        cin >> v;
        --v;
        auto tm = g;
        int res = check(v, tm);
        for(int u = 1; u < n; ++u){
            int tmp = s[u];
            int cur_p = v;
            bool bad = false;
            while(cur_p != -1){
                if(u == cur_p){
                    bad = true;
                    break;
                }
                cur_p = pred[cur_p];
            }
            if(bad) continue;
            tm = g;
            tm[pred[u]].erase(find(all(tm[pred[u]]), u));
            s[u] = 0;
            res = min(res, check(v, tm));
            s[u] = tmp;
        }
        cout << res << ' ';
    }
    return 0;
}