#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
int main()
{
    //cin.tie(nullptr);
    //ios::sync_with_stdio(0);
    int n,q;
    cin >> n >> q;
    vector<int> p(n,-1);
    vector<vector<int>> sons(n);
    for (int i = 1;i < n;i++) {
        cin >> p[i];
        p[i]--;
        sons[p[i]].push_back(i);
    }
    vector<int> s(n);
    for (int i = 0;i < n;i++) {
        cin >> s[i];
    }
    set<pair<int,int>> se;
    for (auto i:sons[0]) {
        se.insert({-s[i],i});
    }
    vector<int> order = {0};
    for (int i = 0;i < n-1;i++) {
        auto x = *se.begin();
        se.erase(x);
        order.push_back(x.second);
        for (auto v:sons[x.second]) {
            se.insert({-s[v],v});
        }
    }
    vector<int> pp(n);
    pp[0] = -1;
    for (auto i:sons[0]) {
        pp[i] = i;
    }
    for (int i = 0;i < n;i++) {
        int v = order[i];
        if (pp[v]!=0) continue;
        pp[v] = pp[p[v]];
    }
    vector<int> ans(n);
    ans[0] = 0;
    vector<int> pcnt(n);
    oset ss;
    for (int i = 1;i < n;i++) {
        int v = order[i];
        int ma = 0;
        if (ss.size()>0) {
            auto x = *ss.find_by_order(0);
            if (x.second==pp[v]) {
                if (ss.size()>1) {
                    ma = -(ss.find_by_order(1)->first);
                }
            }
            else {
                ma = -x.first;
            }
        }
        ans[i] = i-ma;
        ss.erase({-pcnt[pp[v]],pp[v]});
        pcnt[pp[v]]++;
        ss.insert({-pcnt[pp[v]],pp[v]});
    }
    for (int i = 0;i < q;i++) {
        int v;
        cin >> v;
        cout << ans[v-1] << ' ';
    }
    return 0;
}
