#include <bits/stdc++.h>

using namespace std;
#define int long long

int INF = 1e18;

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

vector<int> bfs(int V) {
    int S = s[V];
    s[V] = 0;
    set<pair<int, int> > q;
    vector<int> rs(n);
    q.insert({s[0], 0});
    int ck = 0;
    vector<int> used(n);
    while (!q.empty()) {
        auto [w, v] = *q.rbegin();
        rs[v] = ck;
        used[v] = 1;
        q.erase({w, v});
        for (int u : g[v]) {
            if (!used[u]) {
                q.insert({s[u], u});
            }
        }
        ck++;
    }
    s[V] = S;
    return rs;
}

signed main() {
    cin.tie(0);
    cout.tie(0);
    int q;
    cin >> n >> q;
    g.assign(n, vector<int> (0));
    vector<int> ans(n, n + 1);
    s.assign(n, 0);
    for (int i = 0; i < n - 1; i++) {
        int p; cin >> p; p--;
        g[i + 1].push_back(p);
        g[p].push_back(i + 1);
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int V = 0; V < n; V++) {
        vector<int> r = bfs(V);
        for (int i = 0; i < n; i++) {
            ans[i] = min(ans[i], r[i]);
        }
    }
    while (q--) {
        int v; cin >> v; v--;
        cout << ans[v] << "\n";
    }
    return 0;
}