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

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

void dfs(int x) {
    for (auto u: v[x]) {
        dfs(u);
        pr[u] = x;
        st1[x].insert({0, 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);
    }
    //cout << "HERE" << endl;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < n; i++) {
        ans[i] = N;
    }
    int zn1 = 0;
    dfs(0);
    pr[0] = -1;
    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        x--;
        t[x] = i + 1;
    }
    set <pair <int, int>> st;
    st.insert({c[0], 0});
    while (!st.empty()) {
        auto [c1, pos] = *st.rbegin();
        ans[pos] = zn1;
        int pos11 = pos;
        if (t[pos] != 0) {
            int x = pos;
            int ans2 = ans[pos];
            while (pr[pos] != -1) {
                if (st1[pr[pos]].size() == 0) {
                    pos = pr[pos];
                    continue;
                }
                auto [zn, pos1] = *st1[pr[pos]].rbegin();
                if (pos1 != pos) {
                    ans2 = min(ans2, ans[x] - zn);
                }
                else {
                    auto [zn, pos1] = *(--st1[pr[pos]].rbegin());
                    ans2 = min(ans2, ans[x] - zn);
                }
                pos = pr[pos];
            }
            ans1[t[x] - 1] = ans2;
        }
        pos = pos11;
        int x = pos;
        while (pr[pos] != -1) {
            st1[pr[pos]].erase({cnt[pos], pos});
            cnt[pos]++;
            st1[pr[pos]].insert({cnt[pos], pos});
            pos = pr[pos];
        }
        zn1++;
        st.erase({c1, x});
        for (auto u: v[x]) {
            st.insert({c[u], u});
        }
    }
    for (int i = 0; i < q; i++) {
        cout << ans1[i] << " ";
    }
}

