#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector <vector <ll > > g;
vector <ll > used, s, h;
void dfs_h(ll v, ll hn = 0) {
    h[v] = hn;
    for (auto e : g[v]) {
        dfs_h(e, hn + 1);
    }
}
void solve() {
    ll n, q;
    cin >> n >> q;
    s.resize(n);
    h.resize(n);
    g.resize(n);
    vector <ll > tp;
    for (ll i = 1; i < n; i++) {
        ll p;
        cin >> p;
        p--;
        if (p == 0) {
            tp.push_back(i);
        }
        g[p].push_back(i);
    }
    for (ll i = 0; i < n; i++) {
        cin >> s[i];
    }
    vector <vector <ll > > ansfr(n, vector <ll > (n, 1e18));
    for (auto k : tp) {
        set <pair <ll, ll > > q;
        ll h1 = 0;
        swap(h1, s[k]);
        q.insert({-s[0], 0});
        ll day = 0;
        while (!q.empty()) {
            auto [nsv, v] = *q.begin();
            q.erase(q.begin());
            ansfr[k][v] = day++;
            for (auto e : g[v]) {
                q.insert({-s[e], e});
            }
        }
        swap(h1, s[k]);
    }
    vector <ll > ans(n, 1e18);
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            ans[j] = min(ans[j], ansfr[i][j]);
        }
    }
    for (ll q1 = 0; q1 < q; q1++) {
        ll v;
        cin >> v;
        v--;
        cout << ans[v] << ' ';
    }
    cout << endl;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    ll z; cin >> z; while(z--)
    solve();
    return 0;
}

/*
5 3
3 7 10 1 2

 5 2
 5 4 3 2 1
*/