#include <bits/stdc++.h>

#ifndef  WILEYNE
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#endif

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using ordered_set = __gnu_pbds::tree<int, __gnu_pbds::null_type, std::less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;


using ll = long long;
using ld = long double;

using namespace std;

const int MAX_N = (int) 3e5 + 100;
const double eps = acos(-1);
const int INT_INF = (int) 2e9 + 10;
const int MOD = (int) 1e9 + 7;
auto seet = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(seet);
int n, q;
int deep[MAX_N];
vector<int> graph[MAX_N];
int s[MAX_N];

vector<int> calc_del(int v) {
    int mem = s[v];
    s[v] = 0;
    vector<int> res(n + 1, -1);
    set<pair<int, int>> cur_per;
    for (auto c: graph[1]) {
        cur_per.insert({s[c], c});
    }
    int cur_root = 1;
    for (int i = 0; i < n; ++i) {
        res[cur_root] = i;
        if (i == n - 1) {
            break;
        }
        auto it = cur_per.end();
        --it;
        cur_root = it->second;
        cur_per.erase(it);

        for (auto c: graph[cur_root]) {
            cur_per.insert({s[c], c});
        }
    }
    s[v] = mem;
    return res;
}


vector<int> calc() {
    vector<int> res(n + 1, 1e9);
    vector<int> posl(n);
    for (int i = 1; i <= n; ++i) {
        posl[i - 1] = i;
    }
    shuffle(posl.begin(), posl.end(), rng);
    int it = 0;
    while (it < n && (double) clock() / CLOCKS_PER_SEC < 1.8) {
        vector<int> c = calc_del(posl[it]);
        for (int i = 1; i <= n; ++i) {
            res[i] = min(res[i], c[i]);
        }
        it++;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef WILEYNE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n >> q;
    for (int i = 2; i <= n; ++i) {
        int p;
        cin >> p;
        graph[p].push_back(i);
    }
    for (int i = 0; i < n; ++i) cin >> s[i + 1];
    vector<int> ans = calc();
    for (int i = 0; i < q; ++i) { ;
        int v;
        cin >> v;
        cout << ans[v] << " ";
    }

    return 0;
}
