#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector<ll> p, s;
vector<ll> dp;

vector<ll> st;
vector<ll> mp;
vector<vector<ll>> g;
void dfs(ll v) {
    vector<ll> mem;
    while (st.size() && s[st.back()] > s[v]) {
        mem.push_back(st.back());
        st.pop_back();
    }
    mp[v] = (st.size() ? st.back() : -1);
    st.push_back(v);
    for (int i : g[v]) {
        dfs(i);
    }
    st.pop_back();
    while (mem.size()) {
        st.push_back(mem.back());
        mem.pop_back();
    }
}

const ll INF = 1e18;

struct Treex {
    vector<ll> nd;
    vector<ll> v;
    //vector<ll> psh;
    ll n;
    /*void push(ll u) {
        psh[u * 2 + 1] += psh[u];
        psh[u * 2 + 2] += psh[u];
        nd[u * 2 + 1] += psh[u];
        nd[u * 2 + 2] += psh[u];
        psh[u] = 0;
    }*/
    void build(ll u, ll l, ll r) {
        if (l + 1 == r) {
            nd[u] = v[l];
            return;
        }
        build(u * 2 + 1, l, (l + r) / 2);
        build(u * 2 + 2, (l + r) / 2, r);
        nd[u] = max(nd[u * 2 + 1], nd[u * 2 + 2]);
    }
    Treex() = default;
    Treex(vector<ll> v): v(v), n(v.size()) {
        nd.resize(4 * n, 0);
        build(0, 0, n);
    }
    ll get(ll u, ll l, ll r, ll L, ll R) {
        if (r <= L || R <= l) {
            return -INF;
        }
        if (L <= l && r <= R) {
            return nd[u];
        }
        return max(get(u * 2 + 1, l, (l + r) / 2, L, R), 
        get(u * 2 + 2, (l + r) / 2, r, L, R));
    }
    ll get(ll l, ll r) {
        return get(0, 0, n, l, r);
    }
    void set(ll l, ll x) {
        set(0, 0, n, l, x);
    }
    void set(ll u, ll l, ll r, ll L, ll x) {
        if (r <= L || L < l) {
            return;
        }
        if (l + 1 == r) {
            nd[u] = x;
            return;
        }
        set(u * 2 + 1, l, (l + r) / 2, L, x);
        set(u * 2 + 2, (l + r) / 2, r, L, x);
        nd[u] = max(nd[u * 2 + 1], nd[u * 2 + 2]);
    }
};

struct Tree {
    vector<ll> nd;
    vector<ll> v;
    vector<ll> psh;
    ll n;
    void push(ll u) {
        psh[u * 2 + 1] += psh[u];
        psh[u * 2 + 2] += psh[u];
        nd[u * 2 + 1] += psh[u];
        nd[u * 2 + 2] += psh[u];
        psh[u] = 0;
    }
    void build(ll u, ll l, ll r) {
        if (l + 1 == r) {
            nd[u] = v[l];
            return;
        }
        build(u * 2 + 1, l, (l + r) / 2);
        build(u * 2 + 2, (l + r) / 2, r);
        nd[u] = nd[u * 2 + 1] + nd[u * 2 + 2];
    }
    Tree() = default;
    Tree(vector<ll> v): v(v), n(v.size()) {
        nd.resize(4 * n, 0);
        psh.resize(4 * n, 0);
        build(0, 0, n);
    }
    ll get(ll u, ll l, ll r, ll L, ll R) {
        if (r <= L || R <= l) {
            return 0;
        }
        if (L <= l && r <= R) {
            return nd[u];
        }
        push(u);
        return get(u * 2 + 1, l, (l + r) / 2, L, R) + get(u * 2 + 2, (l + r) / 2, r, L, R);
    }
    ll get(ll l) {
        return get(0, 0, n, l, l + 1);
    }
    void add(ll u, ll l, ll r, ll L, ll R, ll k) {
        if (r <= L || R <= l) {
            return;
        }
        if (L <= l && r <= R) {
            nd[u] += k;
            psh[u] += k;
            return;
        }
        push(u);
        add(u * 2 + 1, l, (l + r) / 2, L, R, k);
        add(u * 2 + 2, (l + r) / 2, r, L, R, k);
    }
    void add(ll l, ll r, ll k) {
        add(0, 0, n, l, r, k);
    }
};

struct HLD {
    vector<vector<ll>> g;
    vector<ll> p;
    vector<ll> sz, pos, eul;
    vector<ll> up;
    vector<set<pair<ll, ll>>> stsz;
    ll n;
    Tree tsz;
    Treex tan;
    void dfsrt(ll v) {
        for (int i : g[v]) {
            dfsrt(i);
            sz[v] += sz[i];
        }
        sort(g[v].begin(), g[v].end(), [&](ll a, ll b){return sz[a] > sz[b];});
    }
    void dfseul(ll v) {
        pos[v] = eul.size();
        eul.push_back(v);
        for (int i : g[v]) {
            dfseul(i);
        }
    }
    void dfsup(ll v) {
        ll f = 1;
        for (int i : g[v]) {
            if (f) up[i] = up[v];
            else {
                up[i] = i;
                stsz[v].insert({sz[i], i});
            }
            f = 0;
            dfsup(i);
        }
    }
    HLD(vector<vector<ll>> gg, vector<ll> pp) {
        p = pp;
        g = gg;
        n = g.size();
        sz.assign(n, 1);
        up.assign(n, 0);
        pos.resize(n);
        stsz.resize(n);
        dfsrt(0);
        dfseul(0);
        dfsup(0);
        vector<ll> trrsz(n);
        for (int i = 0; i < n; i++) {
            trrsz[i] = sz[eul[i]];
        }
        tsz = Tree(trrsz);
        vector<ll> taan(n, 0);
        for (int i = 0; i < n; i++) {
            if (stsz[i].size() == 0) continue;
            taan[pos[i]] = stsz[i].rbegin()->first;

        }
        tan = Treex(taan);
    }
    ll calc_ans(ll v, ll K) {
        ll mxsz = 0;
        //cout << tan.get(1, 2) << endl;
        while (1) {
            int u = up[v];
            mxsz = max(mxsz, tan.get(pos[u], pos[v]));
            if (u == 0) return mxsz;
            int k = p[u];
            if (stsz[k].size() > 2) {
                auto x = stsz[k].rbegin();
                if (x->second == u) x--;
                //cout << v << " " << x->first << " " << x->second << endl;
                mxsz = max(mxsz, x->first);
            }
            if (s[eul[pos[k] + 1]] > K) mxsz = max(mxsz, tsz.get(pos[k] + 1));
            v = k;
        }
        return mxsz;
    }
    vector<int> ind;
    void upd(ll v, ll ad) {
        ll V = v;
        //cout << sz[v] << " " << v << " " << ad << " ";
        while (1) {
            int u = up[v];
            ll usz = tsz.get(pos[u]);
            tsz.add(pos[u], pos[v], ad);
            if (u == 0) break;
            int k = p[u];
            stsz[k].erase({usz, u});
            stsz[k].insert({usz + ad, u});
            tan.set(pos[k], stsz[k].rbegin()->first);
            v = k + 1;
        }
        //cout << tsz.get(pos[0]) << endl;
    }
    void uPd(ll l, ll r) {
        ll ad = -tsz.get(pos[l]);
        upd(l, ad);
        if (r != -1) upd(r, -ad);
    }
};

vector<ll> ans0, ans1, del;

void dfsans(ll v) {
    if (mp[v] == -1) {
        ans1[v] = ans0[v] - del[v];
    } else {
        ans0[v] = ans0[v] + ans0[mp[v]];
        del[v] = max(del[v], del[mp[v]]);
        ans1[v] = ans0[v] - del[v];
    }
    for (auto i : g[v]) dfsans(i);
}

int main() {
    ll n, m;
    cin >> n >> m;
    p.resize(n, -1);
    s.resize(n);
    mp.resize(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    g.resize(n);
    for (int i = 0; i < n; i++) if (i != 0) {
        g[p[i]].push_back(i);
    }
    dfs(0);

    ans0.resize(n);
    ans1.resize(n);
    del.resize(n);

    vector<pair<ll, ll>> vls(n);
    for (int i = 0; i < n; i++) vls[i] = {s[i], i};
    sort(vls.begin(), vls.end());
    HLD hld(g, p);
    for (int i = 0; i < n; i++) {
        hld.uPd(vls[i].second, mp[vls[i].second]);
        del[vls[i].second] = hld.calc_ans(vls[i].second, vls[i].first);
        ll x = mp[vls[i].second];
        ans0[vls[i].second] = hld.tsz.get((x > -1 ? x : 0));
    }

    ans0[0] = 0;

    //for (auto i : ans0) cout << i << endl;
    //for (auto i : del) cout << i << " ";
    //for (auto i : mp) cout << i << endl;

    dfsans(0);

    for (int i = 0; i < m; i++) {
        int q;
        cin >> q;
        q--;
        cout << ans1[q] << " ";
    }
}