#include <bits/extc++.h>
#define int long long
using namespace std;
using namespace __gnu_pbds;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, q; cin >> n >> q;
    vector<int> p(n + 1);
    for (int i = 2; i <= n; ++i) cin >> p[i];
    vector<int> s(n + 1);
    for (int i = 1; i <= n; ++i) cin >> s[i];
    vector<int> ans(n + 1, 1e18);
    auto solve = [&](int bl, vector<int> s) {
        vector<int> g[n + 1];
        for (int i = 2; i <= n; ++i) g[p[i]].push_back(i);
        s[bl] = -1;
        function<void(int, int)> dfs = [&](int v, int time) {
            ans[v] = min(ans[v], time);
            pair<int, int> mx = {-1, -1};
            for (auto to : g[v]) {
                mx = max(mx, pair<int, int>{s[to], to});
            }
            for (auto to : g[v]) {
                if (to != mx.second) g[mx.second].push_back(to);
            }
            if (mx.second == -1) return;
            for (int i = 0; i < g[v].size(); ++i) {
                if (g[v][i] == mx.second) {
                    g[v].erase(g[v].begin() + i);
                    break;
                }
            }
            //if (g[v].size() > g[mx.second].size()) g[v].swap(g[mx.second]);
            for (auto to : g[v]) {
                g[mx.second].push_back(to);
            }
            g[v].clear();
            dfs(mx.second, time + 1);
            return;
        };
        dfs(1, 0);
        return;
    };
    for (int del = 1; del <= n; ++del) {
        solve(del, s);
    }
    while (q--) {
        int v; cin >> v;
        cout << ans[v] << ' ';
    }
    return 0;
}
