#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define db long double

using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

vector<int> ans, s, p;
vector<vector<int>> g;

int t = 0;
vector<int> tin, tout, a;
vector<int> tr;

void dfs(int v) {
    tin[v] = t++;
    a.push_back(v);

    for (int u : g[v]) {
        dfs(u);
    }

    tout[v] = t++;
    a.push_back(v);
}

int query(int n, int l, int r, int ql, int qr, int val) {
    if (ql >= r || l >= qr) return 0;
    if (ql <= l && r <= qr) return tr[n];

    int m = (l + r) / 2;
    return query(2 * n + 1, l, m, ql, qr, val) + query(2 * n + 2, m, r, ql, qr, val);
}

void update(int n, int l, int r, int ql, int val) {
    if (ql >= r || l > ql) return;
    if (r - l == 1) {
        tr[n] = val;
        return;
    }

    int m = (l + r) / 2;
    update(2 * n + 1, l, m, ql, val);
    update(2 * n + 2, m, r, ql, val);

    tr[n] = tr[2 * n + 1] + tr[2 * n + 2];
}

void solve() {
    int n, q; cin >> n >> q;

    g.resize(n + 1), p.resize(n + 1, 0);
    for (int i = 2; i <= n; ++i) {
        int x; cin >> x; p[i] = x;
        g[x].push_back(i);
    }

    s.resize(n + 1), ans.resize(n + 1);
    for (int i = 1; i <= n; ++i) cin >> s[i];


    int cur = 0, root = 1;
    set<pair<int, int>> child;

    for (int u : g[1]) {
        child.insert({-s[u], u});
    }

    while (!child.empty()) {
        ans[root] = cur++;

        auto [wt, i] = *child.begin(); child.erase(child.begin());

        root = i;
        for (int u : g[root]) {
            child.insert({-s[u], u});
        }
    }

    ans[root] = cur;

    tin.resize(n + 1), tout.resize(n + 1);
    dfs(1);

    map<int, int> mp;

    set<pair<int, int>> st;
    vector<int> sz(n + 1, 0);

    for (int u : g[1]) {
        for (int i = tin[u]; i <= tout[u]; ++i) {
            mp[ans[a[i]]] = u;
        }
    }

    vector<int> all;
    for (int i = 1; i <= n; ++i) {
        all.push_back(i);
    }

    std::sort(all.begin(), all.end(), [&](int i1, int i2) {
        return ans[i1] < ans[i2];
    });

    vector<int> res(n, 0);
    for (auto i : all) {
        if (mp.find(ans[i]) == mp.end()) continue;

        res[i] = ans[i];

        auto it = st.begin();
        for (int x = 0; x < 2 && it != st.end(); ++x, ++it) {
            int j = it->second;

            if (tin[j] > tin[i] || tout[j] < tout[i]) {
                res[i] = min(res[i], ans[i] + it->first);
            }
        }

        int j = mp[ans[i]];
        st.erase({-sz[j], j});

        sz[j]++;
        st.insert({-sz[j], j});
    }

    for (int i = 0; i < q; ++i) {
        int v; cin >> v;

        cout << res[v] << ' ';
    }
}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int tt = 1;
    while (tt--) {
        solve();
        cout << "\n";
    }
}