#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];

multiset<pair<int, int>> ms[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);
}
int otv = 0;
pair<int, int> dfs_ans(int v, int cl, int ok = 0)
{
    int mx = 0, e = ok|bool(v == cl);
    for(auto i:g[v])
    {
        pair<int, int> x = dfs_ans(i, cl, ok);
        if(!x.S) mx = max(mx, x.F+bool(f[i] < f[cl]));
        e |= x.S;
    }
    otv = max(otv, mx);
    if(!e)
        otv = max(otv, (int)bool(f[v] < f[cl]));
    return {mx, e};
}


void modif(int v, pair<int, int> a)
{
    ms[v].insert(a);
    if(ms[v].size() > 2) ms[v].erase(--ms[v].end());
}

void upd(int v)
{
    while(v >= 1)
    {
        ms[pr[v]].erase({-h[v], v});
        h[v]++;
        modif(pr[v], {-h[v], v});
        v = pr[v];
    }
}

int get(int v, int e)
{
    int ans = 0;
    for(auto i:ms[v])
        if(i.S != e)
        {
            ans = max(ans, -i.F);
            break;
        }
    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;
        }
        otv = 0;
        int y = dfs_ans(1, i.F).F;
        ans[i.S] = f[i.F]-otv;
    }
    for(int i = 1; i <= q; i++)
        cout<<ans[i]-1<<" ";
}
