#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
//#define int long long

const int N = 3e5 + 100;
vector<int> order, g[N];
int par[N], a[N], siz[N], up[N], timer = 1, tin[N], tout[N], val[N], ans[N], d[N * 4 + 3000], p[N * 4 + 3000], was[N];
pair<int, int> d1[N * 4 + 3000];

void dfs(int v) {
    siz[v] = 1;
    for (int i = 0; i < sz(g[v]); ++i) {
        dfs(g[v][i]);
        siz[v] += siz[g[v][i]];
        if (siz[g[v][i]] > siz[g[v][0]]) {
            swap(g[v][i], g[v][0]);
        }
    }
}

void hld(int v) {
    tin[v] = timer++;
    for (int i : g[v]) {
        if (i == g[v][0]) {
            up[i] = up[v];
        } else {
            up[i] = i;
        }
        hld(i);
    }
    val[tin[v]] = timer - tin[v];
    tout[v] = timer;
}

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

void push(int v) {
    if (p[v] != 0) {
        d[2 * v] += p[v];
        d[2 * v + 1] += p[v];
        p[2 * v] += p[v];
        p[2 * v + 1] += p[v];
        p[v] = 0;
    }
}

inline void update(int v, int l, int r, int x, int y, int zn) {
    if (l > y || x > r) {
        return;
    }
    if (l >= x && r <= y) {
        d[v] += zn;
        p[v] += zn;
        return;
    }
    push(v);
    int m = (l + r) / 2;
    update(2 * v, l, m, x, y, zn);
    update(2 * v + 1, m + 1, r, x, y, zn);
    d[v] = max(d[2 * v], d[2 * v + 1]);
}

vector<pair<int, int>> can;
int now;

int find_ans(int v, int l, int r) {
    while (now >= 0 && can[now].second < l) {
        now--;
    }
    if (now != -1 && can[now].first <= l && can[now].second >= r) {
        return 0;
    }
    if (now == -1 || can[now].first > r) {
        return d[v];
    }
    int m = (l + r) / 2;
    push(v);
    auto x = find_ans(2 * v, l, m);
    return max(x, find_ans(2 * v + 1, m + 1, r));
}

int n, q;

void update1(int v, int l, int r, int pos, int zn) {
    if (l == r) {
        d1[v] = {zn, pos};
        return;
    }
    int m = (l + r) / 2;
    if (pos > m) {
        update1(2 * v + 1, m + 1, r, pos, zn);
    } else {
        update1(2 * v, l, m, pos, zn);
    }
    d1[v] = d1[2 * v];
    if (d1[2 * v + 1].first > d1[2 * v].first) {
        d1[v] = d1[2 * v + 1];
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> q;
    for (int i = 2; i <= n; ++i) {
        cin >> par[i];
        g[par[i]].pb(i);
    }
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    update1(1, 1, n, 1, a[1]);
    for (int i = 0; i < n; ++i) {
        int v = d1[1].second;
        update1(1, 1, n, v, 0);
        for (int j : g[v]) {
            update1(1, 1, n, j, a[j]);
        }
        order.pb(v);
    }
    dfs(1);
    up[1] = 1;
    hld(1);
    build(1, 1, n);
    vector<int> zap(q);
    for (int i = 0; i < q; ++i) {
        cin >> zap[i];
        was[zap[i]] = 1;
    }
    for (int i = n - 1; i >= 0; --i) {
        int v = order[i];
        can.clear();
        int kol = 0;
        while (v > 0) {
            update(1, 1, n, tin[up[v]], tin[v], -1);
            can.pb({tin[up[v]], tin[v]});
            v = par[up[v]];
            kol++;
        }
        now = sz(can) - 1;
        if (i != n - 1 && p[order[i + 1]] == order[i]) {
            ans[order[i]] = ans[order[i + 1]];
            continue;
        }
        if (was[order[i]]) {
            int last = 1, tek = 0;
            tek = max(tek, find_ans(1, 1, n));
            ans[order[i]] = i - tek;
        }
    }
    for (int i = 0; i < q; ++i) {
        cout << ans[zap[i]] << " ";
    }
    return 0;
}
