#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n, q;
vector <int> p, s, v;

vector <int> predd, deep;

vector <vector <int>> g;

void dfs(int v, int pr, int prd, int d) {
    predd[v] = prd;
    deep[v] = d;
    if (pr == 0) {
        prd = v;
    }

    for (auto u : g[v]) {
        dfs(u, v, prd, d + 1);
    }
}

void solve() {
    cin >> n >> q;
    p.resize(n);
    s.resize(n);
    v.resize(q);
    deep.resize(n);
    predd.resize(n);

    g.resize(n);

    int cntp1 = 0;
    int mxp1 = 0;

    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;

        g[p[i]].push_back(i);

        if (p[i] == 0) {
            cntp1++;
        }
    }

    for (int i = 0; i < n; i++) {
        cin >> s[i];

        if (p[i] == 0) {
            mxp1 = max(mxp1, s[i]);
        }
    }
    
    for (int i = 0; i < q; i++) {
        cin >> v[i];
        v[i]--;

        int mn = 1e9;

        for (int j = 0; j < n; j++) {
            int cnt = 0;
            if (j == v[i]) {
                continue;
            }
            int scur = s[j];
            s[j] = 0;

            int cur = 0;
            set <pair <int, int>> st;
            st.emplace(-s[0], 0);

            while (!st.empty()) {
                cur = st.begin()->second;
                st.erase(st.begin());

                //cout << cur << ' ';

                if (cur == v[i]) {
                    mn = min(mn, cnt);
                    break;
                }
                for (auto u : g[cur]) {
                    st.emplace(-s[u], u);
                }
                cnt++;
            }
            s[j] = scur;
        }

        cout << mn << ' ';
    }



}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);


    solve();
    
}

/*

*/