#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll q = 1;
    while (q--) {
        solve();
    }
}

const ll INF = 1e18;

struct Node {
    vector<ll> p;
    vector<set<pair<ll, ll>>> g;
    vector<ll> ans;
    ll cnt = 0;
    ll get(ll x) {
        if (p[x] == x) {
            return p[x];
        }
        p[x] = get(p[x]);
        return p[x];
    }
    void join() {
        cnt++;
        ll root = get(0);
        ll v = g[root].begin()->second;
        g[root].erase(g[root].begin());
        ans[v] = cnt;
        for (auto u : g[v]) {
            g[root].insert(u);
        }
        p[v] = root;
    }
}; 


void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> p(n), s(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    vector<ll> opt(n, INF);
    for (int v = 0; v < n; v++) {
        ll el = s[v];
        s[v] = 0;
        Node tec;
        tec.p.resize(n);
        iota(tec.p.begin(), tec.p.end(), 0);
        tec.g.resize(n);
        tec.ans.resize(n);
        for (int i = 1; i < n; i++) {
            tec.g[p[i]].insert({-s[i], i});
        }
        for (int i = 1; i < n; i++) {
            tec.join();
        }
        for (int i = 0; i < n; i++) {
            opt[i] = min(opt[i], tec.ans[i]);
        }
        s[v] = el;
    }
    for (int i = 0; i < q; i++) {
        ll z;
        cin >> z;
        cout << opt[z - 1] << ' ';
    }
} 