#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int>g[300005 + 1] = {};
int tin[300005];
int tout[300005];
int t = 0;
void dfs(int v) {
    tin[v] = ++t;
    for (auto u : g[v]) {
        dfs(u);
    }
    tout[v] = t;
}
void gogo() {
    int n, m;
    cin >> n >> m;
    int p[n + 1] = {};
    for (int i = 2; i <= n; i++) {
        cin >> p[i];
        g[p[i]].push_back(i);
    }
    int s[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    bool was[n + 1] = {};
    was[1] = 1;
    priority_queue<pair<int, int> >q;
    q.push({s[1], 1});
    int cnt = 0;
    vector<int>ord = {0};
    while (!q.empty()) {
        pair<int, int>m = q.top();
        q.pop();
        ord.push_back(m.second);
        for (auto u : g[m.second]) {
            if (!was[u]) {
                q.push({s[u], u});
                was[u] = 1;
            }
        }
    }
    dfs(1);
    int pos[n + 1];
    for (int i = 1; i <= n; i++) {
        pos[ord[i]] = i;
        // cout << ord[i] << ' ';
    }
    // cout << endl;
    // while (m--) {
    //     int v;
    //     cin >> v;
    //     int ans = 0;
    //     for (int y = 1; y <= n; y++) {
    //         if (!(tin[y] <= tin[v] && tout[v] <= tout[y])) {
    //             ans = max(ans, ans[y]);
    //             // cout << y << ' ' << pref[y][pos[v]] << endl;
    //         }
    //     }
    //     cout << pos[v] - ans - 1 << " ";
    // }
    vector<pair<int, pair<int, int> > >qq;
    int res[m + 1] = {};
    for (int i = 1; i <= m; i++) {
        int v;
        cin >> v;
        qq.push_back({pos[v], {v, i}});
    }
    sort(qq.begin(), qq.end());
    int er = 0;
    int ans[n + 1] = {};
    for (auto u : qq) {
        while (er < u.first) {
            er++;
            int x = ord[er];
            while (x) {
                ans[x]++;
                x = p[x];
            }
        }
        res[u.second.second] = u.first;
        for (int i = 1; i <= n; i++) {
            if (!(tin[i] <= tin[u.second.first] && tout[u.second.first] <= tout[i])) {
                res[u.second.second] = min(res[u.second.second], u.first - ans[i] - 1);
                // cout << i << ' ';
            }
        }
        // cout << endl;
    }
    for (int i = 1; i <= m; i++) {
        cout << res[i] << ' ';
    }
}
main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        gogo();
    }
}
//0 62 21 21
//104