#include<bits/stdc++.h>

#define int long long

using namespace std;

const int MAX = 3e5 + 1;
int tree[4 * MAX], update_tree[4 * MAX];
const int INF = 2e9;

void build (int v, int l, int r) {
    if (l + 1 == r) {
        tree[v] = 0;
        return;
    }
    int m = (l + r) / 2;
    build(2 * v, l, m);
    build(2 * v + 1, m, r);
    tree[v] = max(tree[2 * v], tree[2 * v + 1]);
}

void push(int v) {
    int x = update_tree[v];
    update_tree[v] = 0;
    update_tree[2 * v] += x;
    update_tree[2 * v + 1] += x;
    tree[2 * v] += x;
    tree[2 * v + 1] += x;
}

void update(int v, int l, int r, int ql, int qr, int x) {
    if (qr <= l || r <= ql) return;
    if (ql <= l && r <= qr) {
        tree[v] += x;
        update_tree[v] += x;
        return;
    }
    int m = (l + r) / 2;
    push(v);
    update(2 * v, l, m, ql, qr, x);
    update(2 * v + 1, m, r, ql, qr, x);
    tree[v] = max(tree[2 * v], tree[2 * v + 1]);
}

int get(int v, int l, int r, int ql, int qr) {
    if (r <= ql || qr <= l) {
        return INF;
    }
    if (ql <= l && r <= qr) {
        return tree[v];
    }
    int m = (l + r) / 2;
    push(v);
    return max(get(2 * v, l, m, ql, qr), get(2 * v + 1, m, r, ql, qr));
}

int s[MAX];
vector<int> g[MAX];
vector<int> ord;

void mix() {
    set<pair<int, int>> st;
    st.insert({-s[0], 0});
    while (!st.empty()) {
        int v = st.begin()->second;
        ord.push_back(v);
        st.erase(st.begin());
        for (int to : g[v]) {
            st.insert({-s[to], to});
        }
    }
}

int sz[MAX];

void dfs(int v) {
    sz[v] = 1;
    for (int to : g[v]) {
        dfs(to);
        sz[v] += sz[to];
    }
}

bool cmp(int a, int b) {
    if (sz[a] == sz[b]) {
        return a < b;
    }
    return sz[a] > sz[b];
}

int tin[MAX], head[MAX];
int timer = 0;

void dfs2(int v, int hd) {
    tin[v] = timer++;
    head[v] = hd;
    for (int i = 0; i < min(1ll, (int)g[v].size()); ++i) {
        dfs2(g[v][i], hd);
    }
    for (int i = 1; i < (int)g[v].size(); ++i) {
        dfs2(g[v][i], g[v][i]);
    }
}

int ps[MAX];

void rupdate(int v, int x, int n) {
    while (v != -1) {
        update(1, 0, n, tin[head[v]], tin[v] + 1, x);
        //cout << v << " " << head[v] << endl;
        v = head[v];
        v = ps[v];
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    ps[0] = -1;
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        g[p].push_back(i);
        ps[i] = p;
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    dfs(0);
    //cout << -1 << endl;
    for (int i = 0; i < n; ++i) {
        sort(g[i].begin(), g[i].end(), cmp);
    }
    dfs2(0, 0);
    //cout << -2 << endl;
    mix();
    //cout << -3 << endl;
    build(1, 0, n);
    //cout << -4 << endl;
    vector<int> ans(n);
    for (int i = 0; i < n; ++i) {
        int v = ord[i];
        //cout << v << " " << endl;
        ans[v] = i;
        rupdate(v, -INF, n);
        int u = get(1, 0, n, 0, n);
        ans[v] = min(ans[v], ans[v] - u);
        rupdate(v, INF + 1, n);
    }
    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        --v;
        cout << ans[v] << " ";
    }
    return 0;
}
