#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

// #define FILE
#define int long long



signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    for (int i = 1; i < n; ++i) {
        int x; cin >> x; x--;
        g[i].push_back(x);
        g[x].push_back(i);
    }
    vector<int> s(n), used(n);
    for (int i = 0; i < n; ++i) cin >> s[i];
    vector<int> ans(n, 1e9);
    for (int del = 0; del < n; ++del) {
        int last = s[del];
        s[del] = 0;
        fill(used.begin(), used.end(), 0);
        set<pair<int, int>> st;
        st.insert({-s[0], 0});
        used[0] = 1;
        int timer = 0;
        while (!st.empty()) {
            auto [w, v] = *st.begin();
            ans[v] = min(ans[v], timer);
            timer++;
            st.erase(st.begin());
            for (auto x : g[v]) {
                if (used[x]) continue;
                st.insert({-s[x], x});
                used[x] = 1;
            }
        }
        s[del] = last;
    }

    while (q--) {
        int v; cin >> v; v--;
        cout << ans[v] << " ";
    }
}