#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 3e5 + 7;

set <pair <int, int>> st[N];
int c[N];
vector <int> v[N];
int pr[N];
int t[N];
int ans[N];
int cnt[N];
int otv[N];

void dfs(int x) {
    for (auto u: v[x]) {
        st[x].insert({0, u});
        pr[u] = x;
        dfs(u);
    }
}

signed main() {
    int n, q;
    cin >> n >> q;
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        v[p].push_back(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        t[x - 1] = i + 1;
    }
    set <pair <int, int>> dq;
    dq.insert({c[0], 0});
    int zn = 0;
    dfs(0);
    pr[0] = -1;
    while (!dq.empty()) {
        auto [c1, x] = *dq.rbegin();
        //cout << "! " << x + 1 << endl;
        dq.erase({c1, x});
        ans[x] = zn++;
        if (t[x] != 0) {
            //cout << t[x] << endl;
            int pos = x;
            otv[t[x] - 1] = ans[x];
            while (pr[pos] != -1) {
                //cout << " PR " << pr[pos] + 1 << endl;
                if (st[pr[pos]].size() == 1) {
                    pos = pr[pos];
                    continue;
                }
                if (st[pr[pos]].rbegin()->second != pos) {
                    otv[t[x] - 1] = min(otv[t[x] - 1], ans[x] - st[pr[pos]].rbegin()->first);
                    //cout << st[pr[pos]].rbegin()->first << endl;
                }
                else {
                    auto [num, p] = *(--st[pr[pos]].rbegin());
                    otv[t[x] - 1] = min(otv[t[x] - 1], ans[x] - num);
                    //cout << num << endl;
                }
                pos = pr[pos];
            }
        }
        int pos = x;
        while (pr[pos] != -1) {
            st[pr[pos]].erase({cnt[pos], pos});
            cnt[pos]++;
            st[pr[pos]].insert({cnt[pos], pos});
            pos = pr[pos];
        }
        for (auto u: v[x]) {
            dq.insert({c[u], u});
        }
    }
    for (int i = 0; i < q; i++) {
        cout << otv[i] << " ";
    }
}
