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

using namespace std;

#define int ll
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using ordered_set = __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

mt19937 rnd(time(0));

const int MAXN = 3e5 + 52;
vector<int> g[MAXN];
vector<int> g1[MAXN];
int s[MAXN];
int ans[MAXN];
int p[MAXN];

void count(int n) {
    for (int i = 0; i < n; i++) {
        g1[i] = g[i];
    }
    int root = 0;
    for (int _ = 0; _ < n; _++) {
        int mx = 0;
        for (auto &u: g1[root]) {
            mx = max(mx, s[u]);
        }
        for (auto &u: g1[root]) {
            if (mx == s[u]) {
                ans[u] = min(ans[u], _ + 1);
                for (auto &u1: g1[root])
                    if (u != u1)
                        g1[u].push_back(u1);
                root = u;
                break;
            }
        }
    }
}

inline void solve() {
    fill(ans + 1, ans + MAXN, 1e9);
    int n, q;
    cin >> n >> q;
    vector<int> al;
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        if (p[i] == 0) {
            al.push_back(i);
        }
        g[p[i]].push_back(i);
    }
    for (int i = 0; i < n; i++) cin >> s[i];
    shuffle(all(al), rnd);
    al.resize(1000);
    for (int &i: al) {
        if (p[i] == 0) {
            int tmp = s[i];
            s[i] = 0;
            count(n);
            s[i] = tmp;
        }
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        cout << ans[v] << " ";
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
}