#pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define int long long
// #define ll __int128
using namespace std;
// using namespace __gnu_pbds;
// #define unordered_map gp_hash_table
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

const int INF = (int)1e9 + 7;

int n;
vector<vector<int>> g;
vector<bool> used;
vector<int> h;
vector<int> s;

vector<int> min_t;

void model(int v) {
    vector<int> p;
    int old_s = s[v];
    s[v] = 0;
    p.push_back(0);
    priority_queue<pair<int, int>> st;
    for (int u : g[0]) {
        st.push(pair<int, int>(s[u], u));
    }
    while (!st.empty()) {
        int v = st.top().second;
        st.pop();
        for (int u : g[v]) {
            st.push(pair<int, int>(s[u], u));
        }
        p.push_back(v);
    }
    for (int i = 0; i < n; i++) {
        min_t[p[i]] = min(min_t[p[i]], i);
    }
    s[v] = old_s;
}

void solve() {
    int q;
    cin >> n >> q;
    g.resize(n);
    used.resize(n);
    h.resize(n);
    s.resize(n);
    min_t.resize(n, INF);
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 1; i < n; i++) {
        model(i);
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        cout << min_t[v] << " ";
    }
    cout << "\n";
}

signed main() {
    // cout << fixed << setprecision(20);
    #ifdef LOCAL
    freopen("C:\\work\\input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #endif
    solve();
}