#include <bits/stdc++.h>

using namespace std;
#define int int64_t
void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> p(n + 1, 0);
     vector<vector<int> > a(n + 1);
    for (int i = 2; i <= n; i++) {
            cin >> p[i];
            a[p[i]].push_back(i);
    }
    vector<int> s(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }

    for (int j = 0; j < q; j++) {
        int ans = n;
        int e;
        cin >> e;
        for (int i = 1; i <= n; i++) {
                int g = s[i];
            s[i] = 0;
            set<pair<int,int>, greater<pair<int,int> > > st;
            st.insert({s[1], 1});
            int kol = 0;
            while (st.size() > 0) {
                auto it = st.begin();
                int v = (*it).second;
                //cout << e << " " << i << " " << v << endl;
                st.erase(it);
                if (v == e) {
                    break;
                }
                kol++;
                for (int j = 0; j < a[v].size(); j++) {
                    int u = a[v][j];
                    st.insert({s[u], u});
                }
            }
            ans = min(ans, kol);
            s[i] = g;
        }
        cout << ans << " ";
    }

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

