#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("unroll-loops")
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #pragma GCC target("avx2")
#include<bits/stdc++.h>
// using namespace __gnu_pbds;
using namespace std;
using ll = long long;
// using ordered_map = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
// using hash_map = gp_hash_table<int, int>;
#define watch(x) cout << #x << ": " << x << '\n';
#define watch_arr(arr) cout << #arr << ": "; \
for (int i = 0; i < (int)arr.size(); ++i) { \
    cout << arr[i] << ' '; \
} \
cout << '\n';
#define all(arr) arr.begin(), arr.end()

random_device rd;
mt19937 rnd(rd());

const int INF = 1e9;

vector<vector<int>> g;
vector<int> s;
vector<int> ans;

void bfs(int del) {
    int cnt = -1;
    priority_queue<pair<int, int>> pq;
    pq.push({s[0], 0});
    while (!pq.empty()) {
        auto [c, v] = pq.top();
        pq.pop();
        ++cnt;
        ans[v] = min(ans[v], cnt);
        for (auto to : g[v]) {
            if (to == del) pq.push({0, to});
            else pq.push({s[to], to});
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, q;
    cin >> n >> q;
    g.resize(n);
    s.resize(n);
    ans.resize(n, INF);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        g[p - 1].emplace_back(i);
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }

    for (int i = 0; i < n; ++i) {
        bfs(i);
    }

    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        cout << ans[v - 1] << ' ';
    }

    return 0;
}
