

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 12;
using ll = long long;

mt19937_64 rng (time (0));
int n, q;
int p[N], s[N];
int ans[N];
vector<int> g[N];
int calc (int v = 0) {
    set<pair<int,int>> st;
    for (auto to : g[1]) st.insert ({s[to], to});
    int ct = 0, root = 1;
    while ((int)st.size()) {
        ans[root] = min (ans[root], ct);
        if (root == v) return ct;
        int nxt_root = (*st.rbegin()).second;
        st.erase (--st.end());
        ct += 1;
        for (auto to : g[nxt_root]) st.insert ({s[to], to});
        root = nxt_root;
    }
    return ct;
}
signed main() {
//#ifdef local
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif // local
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> q;
    for (int i = 2; i <= n; ++i) {
        cin >> p[i];
        g[p[i]].push_back (i);
    }
    for (int i = 1; i <= n; ++i) {
        ans[i] = n;
        cin >> s[i];
    }
    for (int i = 1; i <= n; ++i) {
        int was = s[i];
        s[i] = 0;
        calc();
        s[i] = was;
    }
    while (q--) {
        int v;
        cin >> v;
        int res = n;
        for (int i = 1; i <= n; ++i) {
            int was = s[i];
            s[i] = 0;
            res = min (res, calc (v));
            s[i] = was;
        }
        cout << res << ' ';
    }
    cout << '\n';
}
