#include <bits/stdc++.h>

using ll = long long;

using namespace std;

vector<vector<ll>> g, g1;

vector<ll> used, s, p, v, s1;

void dfs(ll v, ll k = 1) {
    used[v] = k;
    ll mx = -1, ind = -1;
    for (ll i : g1[v]) {
        if (used[i] == 0) {
            if (s1[i] > mx) {
                ind = i;
            }
            mx = max(mx, s1[i]);
        }
    }
    if (ind == -1) {
        return;
    }
    for (ll i : g1[v]) {
        if (used[i] == 0) {
            g1[ind].push_back(i);
        }
    }
    dfs(ind, k + 1);
}
void solve() {
    ll n, q;
    cin >> n >> q;
    used.assign(n, 0);
    g.assign(n, vector<ll> (0));
    v.assign(n, 0);
    s.assign(n, 0);
    for (ll i = 0; i < n - 1; i++) {
        ll a;
        cin >> a;
        a--;
        g[a].push_back(i + 1);
        g[i + 1].push_back(a);
    }
    for (ll i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (ll i = 0; i < q; i++) {
        ll a;
        cin >> a;
        a--;
        ll mn = n + 1;
        for (ll j = 0; j < n; j++) {
            if (a != j) {
                g1 = g;
                s1 = s;
                s1[j] = 0;
                used.assign(n, 0);
                if (j == 0) {
                    ll mx = -1, ind = -1;
                    for (ll f : g1[0]) {
                        if (used[f] == 0) {
                            if (s1[f] > mx) {
                                ind = f;
                            }
                            mx = max(mx, s1[f]);
                        }
                    }
                    if (ind == -1) {
                        continue;
                    }
                    for (ll f : g1[0]) {
                        if (used[f] == 0) {
                            g1[ind].push_back(f);
                        }
                    }
                    dfs(ind);
                } else {
                    dfs(0);
                    //cout << a << ' ' << j << ' ' << used[a] << '\n';
                }
                mn = min(mn, used[a]);
            }
        }
        cout << mn - 1 << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    //cin >> t;
    for (ll i = 0; i < t; i++) {
        solve();
    }
    return 0;
}
