#include <bits/stdc++.h>

using namespace std;

#define int long long

int INF = 1e17;
vector<vector<int>> g;

vector<int> get(vector<int>& s) {
    set<pair<int, int>> mai;
    mai.insert({-s[0], 0});
    int cnt = 0;
    vector<int> ans(s.size());
    while (!mai.empty()) {
        ans[mai.begin()->second] = cnt;
        cnt++;
        int u = mai.begin()->second;
        mai.erase(mai.begin());
        for (auto to : g[u]) {
            mai.insert({-s[to], to});
        }
    }
    return ans;
}

void sovel() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    vector<int> s(n);
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }
    for (auto& to : s) cin >> to;
    vector<int> ans = get(s);
    int mx = 0;
    for (auto to : g[0]) mx = max(mx, s[to]);
    for (auto to : g[0]) {
        int val = s[to];
        s[to] = 0;
        auto now = get(s);
        s[to] = val;
        for (int i = 0; i < n; i++) {
            ans[i] = min(ans[i], now[i]);
        }
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        cout << ans[v] << " ";
    }
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        sovel();
    }
}
