#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) {
    int x = 0;

    for (int i = qr; i > 0; i -= (i & -i)) {
        x += tr[i];
    }

    for (int i = ql; i > 0; i -= (i & -i)) {
        x -= tr[i];
    }

    return x;
}

void update(int n, int l, int r, int ql, int val) {
    for (int i = ql + 1; i <= r; i += (i & -i)) {
        tr[i] += val;
    }
}

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);
    tr.resize(4 * a.size(), 0);

    vector<vector<int>> qry(n + 1);

    for (int i = 0; i < q; ++i) {
        int v; cin >> v;
        qry[v].push_back(i);
    }

    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(q);
    for (auto u : all) {
        if (!qry[u].empty()) {
            int x = ans[u], v = u;

            while (p[v] != 0) {
                for (int to : g[p[v]]) {
                    if (to != v) {
                        x = min(x, ans[u] - query(0, 0, a.size(), tin[to], tout[to] + 1, ans[u]) / 2);
                    }
                }

                v = p[v];
            }

            for (int i : qry[u]) res[i] = x;
        }

        update(0, 0, a.size(), tin[u], 1);
        update(0, 0, a.size(), tout[u], 1);
    }

    for (auto el : res) cout << el << ' ';
}

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

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