#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;
vector<vector<int>> sons;
vector<int> tin;
vector<int> tout;
int cnt = 0;
void dfs(int v) {
    tin[v] = cnt++;
    for (auto to:sons[v]) {
        dfs(to);
    }
    tout[v] = cnt++;
}
bool isp(int v,int u) {
    return (tin[u]<=tin[v] and tout[v]<=tout[u]);
}
int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n,q;
    cin >> n >> q;
    vector<int> p(n,-1);
    sons.resize(n);
    tin.resize(n);
    tout.resize(n);
    for (int i = 1;i < n;i++) {
        cin >> p[i];
        p[i]--;
        sons[p[i]].push_back(i);
    }
    dfs(0);
    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> ans(n);
    vector<int> dp(n);
    oset d;
    ans[0] = 0;
    for (int i = 1;i < n;i++) {
        int v = order[i];
        int ma = 0;
        for (auto x:d) {
            int u = x.second;
            if (isp(v,u)) continue;
            ma = -x.first;
            break;
        }
        ans[v] = i-ma;
        int x = v;
        while (x!=-1) {
            d.erase({-dp[x],x});
            dp[x]+=1;
            d.insert({-dp[x],x});
            x = p[x];
        }
        while (d.size()>103) {
            d.erase(*d.find_by_order(103));
        }
    }
    for (int i = 0;i < q;i++) {
        int v;
        cin >> v;
        cout << ans[v-1] << ' ';
    }
    return 0;
}
