#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <tuple>
#include <queue>
#include <cmath>

using namespace std;
using ll = long long;

constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1e18 + 7;

struct SegmentTree {
    struct node {
        ll s = 0;
        ll p = 0;
    };
    vector<node>tree;

    inline int L(int v) { return 2 * v + 1; }
    inline int R(int v) { return 2 * v + 2; }

    void push(int v, int l, int r) {
        int mid = (l + r) / 2;
        tree[L(v)].s += tree[v].p * (mid - l);
        tree[L(v)].p += tree[v].p;
        tree[R(v)].s += tree[v].p * (r - mid);
        tree[R(v)].p += tree[v].p;
    }

    void add(int ql, int qr, ll x, int l, int r, int v) {
        if (l >= qr || r <= ql) return;
        if (ql <= l && r <= qr) {
            tree[v].s += x * (r - l);
            tree[v].p += x;
            return;
        }
        int mid = (l + r) / 2;
        push(v, l, r);
        add(ql, qr, x, l, mid, L(v));
        add(ql, qr, x, mid, r, R(v));
        tree[v].s = tree[L(v)].s + tree[R(v)].s;
    }

    void build(vector<int>& a, int l, int r, int v) {
        if (r - l == 1) {
            tree[v].s = a[l];
            return;
        }
        int mid = (l + r) / 2;
        build(a, l, mid, L(v));
        build(a, mid, r, R(v));
        tree[v].s = tree[L(v)].s + tree[R(v)].s;
    }

    SegmentTree(vector<int>& a) {
        int n = a.size();
        tree.resize(4 * n);
        build(a, 0, n, 0);
    }
};


vector<vector<int>>g;
vector<ll>s;

vector<int>tin;
vector<int>tout;
vector<int>euler;
void dfs(int v) {
    tin[v] = euler.size();
    euler.push_back(v);
    for (int u : g[v]) dfs(u);
    tout[v] = euler.size();
}

int calc(int bad, int V, vector<int>& way) {
    int v = 0;
    if (V == 0) return 0;
    set<pair<ll, int>>pr;
    for (int u : g[v]) {
        if (u == bad) pr.insert({ 0, u });
        else pr.insert({ s[u], u });
    }
    way.push_back(v);
    int cnt = 1;
    while (!pr.empty()) {
        v = pr.rbegin()->second;
        way.push_back(v);
        pr.erase(*pr.rbegin());
        if (v == V) return cnt;
        for (int u : g[v]) {
            if (u == bad) pr.insert({ 0, u });
            else pr.insert({ s[u], u });
        }
        ++cnt;
    }
    return 0;
}

vector<int>fenv;
void add(int i, int x) {
    for (; i < fenv.size(); i += (i & (-i))) {
        fenv[i] += x;
    }
}
int getsum(int i) {
    ll res = 0;
    for (; i > 0; i -= (i & (-i))) {
        res += fenv[i];
    }
    return res;
}
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    vector<int>p(n);
    g.resize(n);
    vector<int>num(n);
    vector<int>x;
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        --p[i];
        g[p[i]].push_back(i);
        if (p[i] == 0) {
            num[i] = i;
            x.push_back(i);
        }
        else {
            num[i] = num[p[i]];
        }
    }
    s.resize(n);
    for (int i = 0; i < n; ++i) cin >> s[i];
    tin.resize(n, -1);
    tout.resize(n, -1);
    dfs(0);
    vector<int>way;
    calc(-1, -1, way);
    vector<int>time(n);
    for (int i = 0; i < n; ++i) {
        time[way[i]] = i;
    }
    vector<tuple<int, int, int>>t(q);

    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        --v;
        t[i] = { time[v], v, i };
    }
    sort(t.begin(), t.end());
    vector<int>ans(q);
    fenv.resize(2 * n + 1);
    int cur = 0;
    priority_queue<pair<int, int>>s;
    for (int i = 0; i < n; ++i) s.push({ 0, i });
    vector<int>cnt(n);
    for (int i = 0; i < n; ++i) {
        while (cur < t.size() && get<0>(t[cur]) < i)++cur;
        if (cur == t.size())break;
        if (cur < t.size() && get<0>(t[cur]) == i) {
            auto [tt, v, ind] = t[cur];
            int u = v;
            int mx = 0;
            vector<pair<int, int>>pull;
            while (!s.empty()) {
                auto [x, y] = s.top();
                pull.push_back({ x, y });
                s.pop();
                if (!(tin[y] <= tin[v] && tout[v] <= tout[y]))
                {
                    mx = s.top().first;break;
                }
            }
            for (auto x : pull) s.push(x);
            ans[ind] = tt - mx;
        }
        int v = way[i];
        int u = v;
        while (1) {
            ++cnt[u];
            s.push({ cnt[u], u });
            if (p[u] == u) break;
            u = p[u];
        }
    }
    for (auto x : ans) cout << x << ' ';
    cout << "\n";


}
