#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 mx;
    };
    vector<node>tree;

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

    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].mx += x * (r - l);
            return;
        }
        int mid = (l + r) / 2;
        add(ql, qr, x, l, mid, L(v));
        add(ql, qr, x, mid, r, R(v));
        tree[v].mx = max(tree[L(v)].mx, tree[R(v)].mx);
    }

    int getmax(int ql, int qr, int l, int r, int v) {
        if (l >= qr || r <= ql) return 0;
        if (ql <= l && r <= qr) return tree[v].mx;
        int mid = (l + r) / 2;
        return max(getmax(ql, qr, l, mid, L(v)), getmax(ql, qr, mid, r, R(v)));
    }
    SegmentTree(vector<int>& a) {
        int n = a.size();
        tree.resize(4 * n);
    }
    SegmentTree(int n) {
        tree.resize(4 * n);
    }
};


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);
    SegmentTree pref(n + 1), suf(n + 1);
    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 mx = max(pref.getmax(0, tin[v], 0, n + 1, 0), suf.getmax(tin[v] + 1, n + 1, 0, n + 1, 0));
            ans[ind] = tt - mx;
        }
        int v = way[i];
        int u = v;
        while (1) {
            pref.add(tout[u] - 1, tout[u], 1, 0, n + 1, 0);
            suf.add(tin[u], tin[u] + 1, 1, 0, n + 1, 0);
            if (u == p[u])break;
            u = p[u];
        }
        //add(tout[way[i]] + 1, 1);
    }
    for (auto x : ans) cout << x << ' ';
    cout << "\n";


}
