#include<bits/stdc++.h>
//#pragma GCC target("avx2")
//#define int long long
#define F first
#define S second

using namespace std;

const int N = 5e5+10;

int pr[N], s[N], h[N], f[N], d[N], ans[N], c[N];

vector<int> g[N];

bool comp(pair<int, int> a, pair<int, int> b)
{
    return f[a.F] < f[b.F];
}

void dfs(int v, int cl)
{
    c[v] = cl;
    for(auto i:g[v])
        dfs(i, cl);
}

void upd(int v)
{
    while(v >= 1)
    {
        h[v]++;
        v = pr[v];
    }
}

int get(int v, int e)
{
    int ans = 0;
    for(auto i:g[v])
        if(i != e)
            ans = max(ans, h[i]);
    if(v <= 1) return ans;
    return max(ans, get(pr[v], v));
}



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int n, q;
    cin>>n>>q;
    for(int i = 2; i <= n; i++)
        cin>>pr[i], g[pr[i]].push_back(i);
    for(int i = 1; i <= n; i++)
        cin>>s[i];
    vector<pair<int, int>> v;
    for(int i = 1; i <= q; i++)
    {
        int x;
        cin>>x;
        v.push_back({x, i});
    }
    for(auto i:g[1])
        dfs(i, i);
    set<pair<int, int>> st;
    st.insert({-s[1], 1});
    int tim = 0;
    while(st.size() > 0)
    {
        int v = (*st.begin()).S;
        st.erase(st.begin());
        f[v] = ++tim;
        d[f[v]] = v;
        for(auto i:g[v])
            st.insert({-s[i], i});
    }
    sort(v.begin(), v.end(), comp);
    int r = 0, pred = -1, id = -1;
    for(auto i:v)
    {
        if(i.F == pred)
        {
            ans[i.S] = ans[id];
            continue;
        }
        for(int j = r+1; j <= f[i.F]; j++)
            upd(c[d[j]]);
        r = f[i.F];
        ans[i.S] = f[i.F]-get(1, c[i.F]);
        pred = i.F; id = i.S;
//        cout<<i.F<<" "<<f[i.F]<<endl;
    }
    for(int i = 1; i <= q; i++)
        cout<<ans[i]-1<<" ";
}




