//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>

using ll = long long;
using ld = long double;
const ll inf = 1e18;

#define all(a) a.begin(), a.end()
#define pb push_back

using namespace std;
using namespace literals;
//using namespace __gnu_pbds;

//using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//gp_hash_table<ll, ll> s;

mt19937 rnd;

void solve();
void precalc();

int main() {
#ifdef LOCAL:
    freopen("INPUT.TXT", "r", stdin);
    freopen("OUTPUT.TXT", "w", stdout);
    const auto start = chrono::steady_clock::now();
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    precalc();
    bool cfmode = false;
    if(cfmode) {
        ll t;
        cin >> t;
        while(t--) {
            solve();
        }
    } else {
        solve();
    }
#ifdef LOCAL:
    const auto end = chrono::steady_clock::now();
    cout << "\n";
    cout << fixed << setprecision(10) << "xxxTIMExxx: " << (end - start) / 1ms;
#endif
}

void precalc() {

}

vector<ll> p;
vector<vector<ll>> g;
vector<ll> colors;

void dfs(ll v, ll color) {
    if(color == 0) {
        color = v;
    }
    colors[v] = color;
    for(auto i : g[v]) {
        if(i != p[v]) {
            dfs(i, color);
        }
    }
}

void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> s;
    g.assign(n, {});
    p.assign(n, -1);
    colors.resize(n, 0);
    for(int i = 1; i < n; i++) {
        ll x;
        cin >> x;
        x--;
        g[i].pb(x);
        g[x].pb(i);
        p[i] = x;
    }
    s.assign(n, 0);
    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }
    if(n * q > 1e8 + 500) {
        vector<ll> tour;
        set<pair<ll, ll>> s1;
        s1.insert({s[0], 0LL});
        while(s1.size() > 0) {
            ll x = s1.rbegin()->second;
            s1.erase(*s1.rbegin());
            tour.pb(x);
            for(auto i : g[x]) {
                if(i != p[x]) {
                    s1.insert({s[i], i});
                }
            }
        }

        vector<ll> e_tour;
        deque<ll> q1;
        q1.pb(0);
        while(q1.size() > 0) {
            ll x = q1.front();
            q1.pop_front();
            e_tour.pb(x);
            for(auto i : g[x]) {
                if(i != p[x]) {
                    q1.pb(i);
                }
            }
        }
        reverse(all(e_tour));

        vector<bool> was(n, false);
        vector<ll> qt(q);
        for(int i = 0; i < q; i++) {
            cin >> qt[i];
            qt[i]--;
            was[qt[i]] = true;
        }
        map<ll, ll> answers;
        vector<multiset<ll>> al(n);
        for(int i = 1; i < n; i++) {
            if(p[i] != -1) {
                al[p[i]].insert(0);
            }
        }
        vector<ll> sum(n, 0);
        for(int i = 0; i < tour.size(); i++) {
            ll v = tour[i];
            while(v != -1) {
                if(p[v] != -1) {
                    al[p[v]].erase(al[p[v]].find(sum[v]));
                    al[p[v]].insert(sum[v] + 1);
                }
                sum[v]++;
                v = p[v];
            }
            if(was[tour[i]]) {
                ll ans = 0;
                v = p[tour[i]];
                ll last = tour[i];
                while(v != -1) {
                    ll mx = *al[v].rbegin();
                    if(mx == sum[last]) {
                        al[v].erase(al[v].find(mx));
                        if(al[v].size() != 0) {
                            ans = max(ans, *al[v].rbegin());
                        }
                        al[v].insert(mx);
                    } else {
                        ans = max(ans, mx);
                    }
                    last = v;
                    v = p[v];
                }
                answers[tour[i]] = i - ans;
            }
        }
        for(int i = 0; i < q; i++) {
            cout << answers[qt[i]] << " ";
        }
    } else {
        vector<ll> tour;
        set<pair<ll, ll>> s1;
        s1.insert({s[0], 0LL});
        while(s1.size() > 0) {
            ll x = s1.rbegin()->second;
            s1.erase(*s1.rbegin());
            tour.pb(x);
            for(auto i : g[x]) {
                if(i != p[x]) {
                    s1.insert({s[i], i});
                }
            }
        }

        vector<ll> e_tour;
        deque<ll> q1;
        q1.pb(0);
        while(q1.size() > 0) {
            ll x = q1.front();
            q1.pop_front();
            e_tour.pb(x);
            for(auto i : g[x]) {
                if(i != p[x]) {
                    q1.pb(i);
                }
            }
        }
        reverse(all(e_tour));

        vector<bool> was(n, false);
        vector<ll> qt(q);
        for(int i = 0; i < q; i++) {
            cin >> qt[i];
            qt[i]--;
            was[qt[i]] = true;
        }
        vector<ll> sums;
        vector<ll> add;
        sums.resize(n, 0);
        add.resize(n, 0);
        map<ll, ll> answers;
        for(int i = 0; i < tour.size(); i++) {
            add[tour[i]] += 1;
            if(was[tour[i]]) {
                for(int j = 0; j < e_tour.size(); j++) {
                    sums[e_tour[j]] += add[e_tour[j]];
                    if(p[e_tour[j]] != -1) {
                        add[p[e_tour[j]]] += add[e_tour[j]];
                    }
                    add[e_tour[j]] = 0;
                }
                ll ans = 0;
                ll v = tour[i];
                while(p[v] != -1) {
                    ll last = v;
                    v = p[v];
                    for(auto j : g[v]) {
                        if(last == j || j == p[v]) {
                            continue;
                        }
                        ans = max(ans, sums[j]);
                    }
                }
                answers[tour[i]] = i - ans;
            }
        }
        for(int i = 0; i < q; i++) {
            cout << answers[qt[i]] << " ";
        }
    }
}
