#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//.find_by_order(1); по индексу
//.order_of_key(1);

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve();

int32_t main() {
#ifdef LOCAL
    freopen("Input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}

constexpr int MAXN = 3e5 + 1;
constexpr ll INF = 1e18;

vector<int> graph[MAXN], k[MAXN];
int s[MAXN], tin[MAXN], tout[MAXN], p[MAXN];
int timer = 0;

void dfs(int v, int p) {
    tin[v] = timer++;
    for (int u: graph[v]) {
        if (u == p) continue;
        dfs(u, v);
    }
    tout[v] = timer++;
}

bool anc(int a, int b) {
    return tin[a] <= tin[b] && tout[a] > tout[b];
}

void solve() {
    int n, q;
    cin >> n >> q;
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        graph[p[i]].emplace_back(i);
    }
    dfs(0, 0);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    vector<vector<int>> os(n);
    for (int i = 0; i < n; ++i) {
        vector<int> pos(n, 1e9);
        set<pair<int, int>> st = {{0, 0}};
        int cnt = 0;
        while (!st.empty()) {
            auto [_, v] = *st.begin();
            st.erase(st.begin());
            if (v == i) continue;
            pos[v] = cnt++;
            for (int u: graph[v]) {
                st.emplace(-s[u], u);
            }
        }
        os[i] = pos;
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        int ans = 1e9;
        for (int i = 0; i < n; ++i) {
            ans = min(ans, os[i][v]);
        }
        cout << ans << ' ';
    }
}