// #include <string>
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

using ld = long double;
using ll = long long;

//#define int long long

int n;
vector<vector<int>> g;
vector<int> p, s;

void dfs(int u, int pre, int &c, vector<int> &clr) {
    if (clr[u] == -1) {
        if (clr[p[u]] == 0) {
            clr[u] = c;
            c++;
        } else {
            clr[u] = clr[p[u]];
        }
    }
    for (auto v : g[u]) {
        if (v != pre) {
            dfs(v, u, c, clr);
        }
    }
}

void solve() {
    int q, x;
    cin >> n >> q;
    g.resize(n);
    p.resize(n);
    s.resize(n);
    p[0] = -1;
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        g[i].push_back(p[i]);
        g[p[i]].push_back(i);
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    vector<int> clr(n), cnt(n);
    vector<int> ord;
    set<pair<int, int>> st;
    st.insert({s[0], 0});
    while (!st.empty()) {
        int u = (--st.end())->second;
        st.erase(--st.end());
        ord.push_back(u);
        for (auto v : g[u]) {
            if (v != p[u]) {
                st.insert({s[v], v});
            }
        }
    }
    vector<int> nord(n);
    for (int i = 0; i < q; ++i) {
        cin >> x;
        x--;
        fill(clr.begin(), clr.end(), -1);
        fill(cnt.begin(), cnt.end(), 0);
        int cur = x;
        while (cur != -1) {
            clr[cur] = 0;
            cur = p[cur];
        }
        int c = 1;
        dfs(0, -1, c, clr);
        for (int i = 0; i < n; ++i) {
            nord[i] = clr[ord[i]];
        }
        
        int j = 0;
        while (ord[j] != x) {
            cnt[nord[j]]++;
            j++;
        }
        int mx = 0;
        for (int z = 1; z < n; ++z) {
            mx = max(mx, cnt[z]);
        }
        cout << j - mx << ' ';
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int tt = 1;
    //cin >> tt;
    for (int i = 0; i < tt; ++i) {
        solve();
        //cout << '\n';
    }
}