#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

void fast_in_out() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

#define int long long
#define all(x) (x).begin(), (x).end()
using ll = long long;
using ull = long long;
using ld = long double;
typedef tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 3e5;
int n, q, p[N], s[N], ans[N], pos[N], sz[N], h[N], lead[N], num[N], nm = 0;
vector<int> g[N], order;

void dfs0(int v = 0) {
    sz[v] = 1;
    for (auto to: g[v]) {
        h[to] = h[v] + 1;
        dfs0(to);
        sz[v] += sz[to];
    }
    for (int i = 0; i < (int) g[v].size(); ++i) {
        if (sz[g[v][i]] > sz[g[v][0]]) {
            swap(g[v][i], g[v][0]);
        }
    }
}

void dfs1(int v = 0, int ld = 0) {
    lead[v] = ld;
    num[v] = nm++;
    if (!g[v].empty()) {
        dfs1(g[v][0], ld);
        for (int i = 1; i < (int) g[v].size(); ++i) {
            dfs1(g[v][i], g[v][i]);
        }
    }
}

int t[4 * N], ps[4 * N], zn[4 * N];

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

void add(int v, int l, int r, int L, int R) {
    if (R <= l || r <= L) {
        return;
    }
    if (L <= l && r <= R) {
        ++t[v];
        ++ps[v];
        return;
    }
    push(v);
    int m = (l + r) / 2;
    add(2 * v + 1, l, m, L, R);
    add(2 * v + 2, m, r, L, R);
    t[v] = max(t[2 * v + 1], t[2 * v + 2]);
}

void zan(int v, int l, int r, int L, int R) {
    if (R <= l || r <= L) {
        return;
    }
    if (L <= l && r <= R) {
        zn[v] = 0;
        return;
    }
    push(v);
    int m = (l + r) / 2;
    zan(2 * v + 1, l, m, L, R);
    zan(2 * v + 2, m, r, L, R);
    t[v] = max(t[2 * v + 1] * zn[2 * v + 1], t[2 * v + 2] * zn[2 * v + 2]);
}

void otk(int v, int l, int r, int L, int R) {
    if (R <= l || r <= L) {
        return;
    }
    if (L <= l && r <= R) {
        zn[v] = 1;
        return;
    }
    push(v);
    int m = (l + r) / 2;
    otk(2 * v + 1, l, m, L, R);
    otk(2 * v + 2, m, r, L, R);
    t[v] = max(t[2 * v + 1], t[2 * v + 2]);
}

void add(int v) {
    while (v != -1) {
        add(0, 0, n, num[lead[v]], num[v] + 1);
        v = p[lead[v]];
    }
}

void zan(int v) {
    while (v != -1) {
        zan(0, 0, n, num[lead[v]], num[v] + 1);
        v = p[lead[v]];
    }
}

void otk(int v) {
    while (v != -1) {
        otk(0, 0, n, num[lead[v]], num[v] + 1);
        v = p[lead[v]];
    }
}

void solve() {
    cin >> n >> q;
    p[0] = -1;
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        --p[i];
        g[p[i]].emplace_back(i);
    }
    dfs0();
    dfs1();
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < 4 * n; ++i) {
        zn[i] = 1;
    }
    set<pair<int, int>> st;
    st.insert({s[0], 0});
    while (!st.empty()) {
        auto [d, v] = *(--st.end());
        st.erase(--st.end());
        order.emplace_back(v);
        pos[v] = (int) order.size() - 1;
        for (auto to: g[v]) {
            st.insert({s[to], to});
        }
    }
    for (auto v: order) {
        add(v);
        zan(v);
        ans[v] = pos[v] - t[0] * zn[0];
        otk(v);
    }
    while (q--) {
        int x;
        cin >> x;
        --x;
        cout << ans[x] << ' ';
    }
}

signed main() {
    fast_in_out();
    int qwe = 1;
//    cin >> qwe;
    while (qwe--) {
        solve();
    }
    return 0;
}
