//#pragma GCC optimize("unroll-loops,Ofast")
//#pragma GCC target("sse,sse2,avx,avx2")

#include <bits/stdc++.h>

using namespace std;
const int inf = 1e9;

vector<set<pair<int, int>>> g;
vector<int> s, pr;
vector<int> poses;
int n;

void get_poses(int v) {
    poses.assign(n, 0);
    auto g1 = g;
    if (v) {
        g1[pr[v]].erase({s[v], v});
        g1[pr[v]].insert({0, v});
    }
    int root = 0;
    int tim = 0;
    while (true) {
        poses[root] = tim++;
        if (g1[root].empty())break;
        auto z = --g1[root].end();
        int r1 = z->second;
        g1[root].erase(z);
        if (g1[root].size() > g1[r1].size()) {
            swap(g1[root], g1[r1]);
        }
        for (auto to: g1[root]) {
            g1[r1].insert(to);
        }
        root = r1;
    }
}

vector<int> depth;

void dfs(int v, int d) {
    depth[v] = d;
    for (auto to: g[v]) {
        dfs(to.second, d + 1);
    }
}

void solve() {
    int q;
    cin >> n >> q;
    pr.assign(n, 0), s.assign(n, 0), g.assign(n, {});
    depth.assign(n, 0);
    for (int i = 1; i < n; ++i) {
        cin >> pr[i];
        pr[i]--;
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    for (int i = 1; i < n; ++i) {
        g[pr[i]].insert({s[i], i});
    }
    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        v--;
        int mn = n;
        for (int j = 0; j < n; ++j) {
            get_poses(j);
            mn = min(mn, poses[v]);
        }
        cout << mn << " ";
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int _ = 1;
    //cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}
