#include "bits/stdc++.h"
using namespace std;
# define int long long
# define all(a) a.begin(), a.end()
vector<int> s;
struct cmp{
    bool operator()(int a, int b) const{
        return s[a] > s[b];
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    vector<int> pred(n, -1);
    for(int i = 1; i < n; ++i){
        int p;
        cin >> p;
        --p;
        pred[i] = p;
        g[p].push_back(i);
    }
    vector<int> tin(n), tout(n);
    int timer = 0;
    auto dfs = [&](auto &&self, int v) ->void{
        tin[v] = timer++;
        for(auto u : g[v]){
            self(self, u);
        }
        tout[v] = timer++;
    };
    dfs(dfs, 0);
    auto is_parent = [&](int v, int par){
        return tin[par] <= tin[v] && tout[v] <= tout[par];
    };
    s.resize(n);
    for(auto &i : s) cin >> i;
    set<int, cmp> opened;
    opened.insert(all(g[0]));
    vector<int> pos{0};
    while(!opened.empty()){
        int v = *opened.begin();
        opened.erase(opened.begin());
        pos.push_back(v);
        opened.insert(all(g[v]));
    }
    vector<int> wans(n);
    for(int i = 0; i < pos.size(); ++i){
        wans[pos[i]] = i;
    }
    vector<int> ans(n), cnt(n);
    vector<multiset<int>> cm(n);
    for(int v = 0; v < n; ++v){
        for(auto &u : g[v]){
            cm[v].insert(cnt[u]);
        }
    }
    for(auto v : pos){
        int p = pred[v];
        int res = 0;
        int pref = v;
        while(p != -1){
            cm[p].extract(cnt[pref]);
            if(!cm[p].empty()){
                res = max(res, *cm[p].rbegin());
            }
            ++cnt[pref];
            cm[p].insert(cnt[pref]);
            pref = p;
            p = pred[p];
        }
//        p = v;
//        while(p != -1){
//            cnt[p]++;
//            p = pred[p];
//        }
        ans[v] = wans[v] - res;
    }
    while(q--){
        int v;
        cin >> v;
        --v;
        cout << ans[v] << ' ';
    }
    return 0;
}