#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("02")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define int long long
const int N = 1000;
vector<int> g[N];
int s[N];
int n;
set<int> nowg[N];
int calc(int st){
    //vector<bool> was(n, false);
    for (int i = 0 ;i < n; i++){
        nowg[i].clear();
        for (auto el : g[i]){
            nowg[i].insert(el);
        }
    }
    int root = 0;
    int res = 0;
    while (root != st){
        //was[root] = true;
        res++;
        int bst = -1;
        for (auto el : nowg[root]){
            /*if (was[el]){
                continue;
            }*/
            if (bst == -1 ){
                bst = el;
            } else if (s[el] > s[bst]){
                bst = el;
            }
        }
        for (auto el : nowg[root]){
            nowg[el].erase(root);
            if (el != bst){
                nowg[bst].insert(el);
            }
        }
        nowg[root].clear();
        root = bst;
    }
    return res;
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q;
    cin >> n >>  q;
    for (int i = 1; i < n; i++){
        int x;
        cin >> x;
        x--;
        g[i].push_back(x);
        g[x].push_back(i);
    }
    for (int i = 0 ;i < n; i++){
        cin >> s[i];
    }
    while (q--){
        int v;
        cin >> v;
        v--;
        int res = n;
        for (int i = 0; i < n; i++){
            int r = s[i];
            s[i] = 0;
            res = min(res, calc(v));
            s[i] = r;
        }
        cout << res <<" ";
    }
}
