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

using namespace std;
using namespace __gnu_pbds;

#define int long long
using ll = long long;

typedef tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int inf = 1e9 + 7;
const ll inf_ = 1e18 + 7;
const int mod = 998244353;

struct Fast {
    vector<vector<int>> g;
    vector<int> s;
    vector<int> ans;
    vector<int> par;

    void dfs(int v, int pr) {
        par[v] = pr;
        for (auto u: g[v]) {
            dfs(u, (pr == -1 ? u : pr));
        }
    }

    void solve() {
        int n, q;
        cin >> n >> q;
        g.resize(n);
        for (int i = 1; i < n; i++) {
            int x;
            cin >> x;
            x--;
            g[x].push_back(i);
        }
        s.resize(n);
        ans.resize(n, inf);
        par.resize(n);
        for (auto &i: s) cin >> i;
        ans[0] = 0;
        dfs(0, -1);
        map<int, int> cnt;
        pair<int, int> mx1 = {0, -1}, mx2 = {0, -1};
        set<pair<int, int>> t;
        for (auto u: g[0]) t.insert({s[u], u});
        int ind = 1;
        int root = 0;
        while (!t.empty()) {
            root = (--t.end())->second;
            ans[root] = min(ans[root], ind - (mx1.second == par[root] ? mx2.first : mx1.first));
            cnt[par[root]]++;
            pair<int, int> p = {cnt[par[root]], par[root]};
            if (p.first >= mx1.first) mx2 = mx1, mx1 = p;
            else mx2 = max(mx2, p);
            t.erase(--t.end());
            for (auto u: g[root]) t.insert({s[u], u});
            ind++;
        }
        while (q--) {
            int x;
            cin >> x;
            x--;
            cout << ans[x] << ' ';
        }
    }
};

signed main() {
    int __ = 1;
    //cin >> __;
    while (__--) {
        Fast().solve();
        cout << '\n';
    }
    return 0;
}
