#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#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<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);
}

void init(int n, int l, int r) {
    if (r - l == 1) {
        tr[n] = {ans[a[l]]};
        return;
    }

    int m = (l + r) / 2;
    init(2 * n + 1, l, m);
    init(2 * n + 2, m, r);

    merge(tr[2 * n + 1].begin(), tr[2 * n + 1].end(), tr[2 * n + 2].begin(), tr[2 * n + 2].end(), back_inserter(tr[n]));
}

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 lower_bound(tr[n].begin(), tr[n].end(), val) - tr[n].begin();

    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 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());
    init(0, 0, a.size());

    for (int i = 0; i < q; ++i) {
        int v; cin >> v;
        int x = ans[v], u = v;

        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];
        }

        cout << x << ' ';
    }
}

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

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