#include<iostream>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

#define ll long long

vector<vector<ll>> gr;
vector<ll> d;

void dfs1(ll v, ll d1) {
    d[v] = d1;
    for (auto elem : gr[v]) {
        dfs1(elem, d1 + 1);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, q;
    cin >> n >> q;
    vector<ll> p(n);
    gr.resize(n);
    for (ll i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        gr[p[i]].push_back(i);
    }
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    d.resize(n);
    dfs1(0, 0);
    vector<ll> answer(n, 1e18);
    for (ll i1 = 0; i1 < n; i1++) {
        ll answer1 = 0;
        ll x1 = a[i1];
        a[i1] = 0;
        set<pair<ll, ll>> s1;
        for (ll i = 0; i < n; i++) {
            if (d[i] == 1) {
                s1.insert({a[i], i});
            }
        }
        while (!s1.empty()) {
            answer1++;
            pair<ll, ll> p1 = *(--s1.end());
            answer[p1.second] = min(answer[p1.second], answer1);
            s1.erase((--s1.end()));
            for (auto elem : gr[p1.second]) {
                s1.insert({a[elem], elem});
            }
        }
        a[i1] = x1;
    }
    while (q--) {
        ll v;
        cin >> v;
        v--;
        if (v == 0) {
            cout << 0 << " ";
            continue;
        }
        cout << answer[v] << " ";
    }
}