#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#pragma GCC optimize("Ofast")

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;

ll inf = (ll)1e18;

template<class T>
ll len(T& a) {
    return (ll)a.size();
}

ll n, q;
vector<vector<ll>> g;
vector<ll> s;
vector<ll> queries;

void solve() {
    cin >> n >> q;
    ll x;
    g.resize(n);
    s.resize(n);
    queries.resize(q);
    for (ll i = 1; i < n; ++i) {
        cin >> x;
        x--;
        g[x].push_back(i);
    }
    for (ll i = 0; i < n; ++i) {
        cin >> s[i];
    }
    for (ll i = 0; i < q; ++i) {
        cin >> queries[i];
        queries[i]--;
    }

    vector<ll> topsort;
    priority_queue<pair<ll, ll>> que;
    que.push({s[0], 0});
    while (!que.empty()) {
        pair<ll, ll> temp = que.top(); que.pop();
        topsort.push_back(temp.second);
        for (ll to : g[temp.second]) {
            que.push({s[to], to});
        }
    }

    map<ll, ll> met;
    for (ll i = 0; i < len(topsort); ++i) {
        met[topsort[i]] = i;
    }

    for (ll i = 0; i < q; ++i) {
        if (met[queries[i]] < 1) {
            cout << met[queries[i]] << " ";
        } else {
            cout << met[queries[i]] - 1 << " ";
        }
    }
    cout << "\n";
}


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}