#define _GLIBCXX_DEBUG
#define _GLIBCXX_DEBUG_PEDANTIC

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define OPTIMIZETHISSHIT ios::sync_with_stdio(false); cin.tie(nullptr);
#define int long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937_64 rng(0);

int rand(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

int n;
vector<vector<int>> g;
vector<vector<int>> dp;
vector<int> s;

void dfs(int v, int p) {
    for (int u : g[v]) {
        dfs(u, v);
    }
    for (int i = 1; i <= s[v]; i++) {
        dp[v][i] = 1;
        for (int u : g[v]) {
            if (i <= s[u]) {
                dp[v][i] += dp[u][i];
            }
        }
    }
}

void solve() {
    int q;
    cin >> n >> q;
    g.resize(n + 1);
    s.resize(n + 1);
    dp.resize(n + 1, vector<int>(n + 1));
    vector<int> p(n + 1);
    for (int i = 2; i <= n; i++) {
        cin >> p[i];
        g[p[i]].pb(i);
    }
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    dfs(1, 1);
    queue<int> qr;
    qr.push(1);
    vector<int> ans_0(n + 1), ans_1(n + 1);
    cout << "worked" << endl;
    while (!qr.empty()) {
        int v = qr.front(), pv = p[v];
        qr.pop();
        if (v == 1) {
            for (int u : g[v]) {
                qr.push(u);
            }
            continue;
        }
        multiset<int, greater<>> res;
        for (int u : g[pv]) {
            if (u == v) continue;
            if (s[v] != n) {
                res.insert(dp[u][s[v] + 1]);
            } else {
                res.insert(0);
            }
        }
        for (int u : g[v]) {
            qr.push(u);
        }

        int sm = 0;
        for (int i : res) sm += i;
        ans_0[v] = ans_0[pv] + sm + 1;
        ans_1[v] = ans_1[pv] + sm + 1;

        if (!res.empty()) res.erase(res.begin());
        sm = 0;
        for (int i : res) sm += i;
        ans_1[v] = min(ans_1[v], ans_0[pv] + sm + 1);

    }
//    for (int i = 1; i <= n; i++) {
//        cout << ans[i] << ' ';
//    }
//    cout << endl;
    for (int i = 0; i < q; i++) {
        int v;
        cin >> v;
        cout << min(ans_0[v], ans_1[v]) << ' ';
    }
    cout << endl;
}

signed main() {
    OPTIMIZETHISSHIT

    solve();
}