#include "bits/stdc++.h"
using namespace std;

#define forn(i,n) for(int i=0;i<n;++i)
#define fornn(i,l,r) for(int i=l;i<=r;++i)
#define ford(i,n) for(int i=n-1;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

const int maxn=1e5+7;
const int logn = 32;
const int mod = 1e9 + 7;

vector<int> parent;
vector<vector<int>> g;
vector<int> s,d;
int n, q, need;

void find() {
    set<pii, greater<>> st;
    vector<bool> used(n, false);
    st.insert({0, 0});
    int timer = 0;
    while (!st.empty()) {
        auto v=st.begin()->ss;
        d[v]=min(d[v],timer++);
        used[v]=true;
        st.erase(st.begin());
        for(auto i:g[v]) {
            if (!used[i])
                st.insert({s[i],i});
        }
    }
}

void solve() {
    cin>>n>>q;
    parent.assign(n, 0);
    g.assign(n, {});
    s.assign(n, 0);
    d.assign(n,1e9);
    d[0]=0;
    forn(i,n-1){
        int p; cin>>p;p--;
        parent[i+1]=p;
        g[p].pb(i+1);
        g[i+1].pb(p);
    }
    forn(i,n) cin>>s[i];

    forn(v,n) {
        if (parent[v]!=0 && g[parent[v]].size()==2) continue;
        int c=s[v]; s[v]=0;
        find();
        s[v]=c;
    }

    forn(i,q) {
        int v; cin>>v; v--;
        cout<<d[v]<<endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

#ifdef LOCAL
    freopen("C:\\work\\untitled\\c.txt", "r", stdin);
    freopen("C:\\work\\untitled\\out.txt", "w", stdout);

    while (!cin.eof()) {
        solve();
        cout<<endl;
    }
#else
    solve();
#endif

    return 0;
}
