#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);
    while (q--) {
        ll v;
        cin >> v;
        v--;
        if (v == 0) {
            cout << 0 << " ";
            continue;
        }
        vector<ll> ind;
        for (ll i = 0; i < n; i++) {
            if (d[i] == 1) {
                ind.push_back(i);
            }
        }
        ll answer1 = 1e18;
        for (auto i1 : ind) {
            ll answer = 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 (true) {
                answer++;
                pair<ll, ll> p1 = *(--s1.end());
                s1.erase((--s1.end()));
                if (p1.second == v) {
                    break;
                }
                for (auto elem : gr[p1.second]) {
                    s1.insert({a[elem], elem});
                }
            }
            answer1 = min(answer1, answer);
            a[i1] = x1;
        }
        cout << answer1 << " ";
    }
}