#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define sll __int128
#define size(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int long long

mt19937 rnd(time(0));

vector<int> get(int n, vector<vector<int>> &g, vector<int> &s){
    set<pair<int, int>> ord = {{-s[0], 0}};
    vector<int> a(n);
    int k = 0;
    while (!ord.empty()){
        auto [w, v] = *ord.begin();
        ord.erase(ord.begin());
        for (auto to : g[v]){
            ord.insert({-s[to], to});
        }
        a[v] = k++;
    }
    return a;
}

void solve(){
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    vector<int> pr(n);
    for (int i = 1; i < n; i++){
        int p; cin >> p; p--;
        g[p].push_back(i);
        pr[i] = p;
    }
    vector<int> s(n);
    for (auto &x : s){
        cin >> x;
    }
    vector<int> ans(n, n);
    for (int i = 0; i < n; i++){
        int ss = s[i];
        s[i] = 0;
        auto a = get(n, g, s);
        s[i] = ss;
        for (int j = 0; j < n; j++){
            ans[j] = min(ans[j], a[j]);
        }
    }
    for (int i = 0; i < q; i++){
        int x; cin >> x; x--;
        cout << ans[x] << " ";
    }
}

signed main(){
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int ttt = 1;
    //cin >> ttt;
    while (ttt--){
        solve();
    }
}
