#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long INF = 1e18, MOD = 1e9 + 7;

void solve();

vector <vector <int>> g;
vector <int> par;
vector <int> a;
vector <int> way;
int get(int v){
    way.push_back(par[v]);
    if (par[v] <= 0){
        return v;
    }
    return get(par[v]);
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    g.resize(n);
    par.resize(n);
    par[0] = -1;
    int fl = 1;
    for (int i = 1; i < n; i++){
        int p;
        cin >> p;
        p--;
        if (p != i - 1){
            fl = 0;
        }
        par[i] = p;
        g[p].push_back(i);
    }
    a.resize(n);
    vector <pair <int, int>> a1(n - 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a1[i - 1] = {a[i], i};
    }
    vector <int> sz(n);
    set <pair <int, int>> st;
    st.insert({a[0], 0});
    int f = 0;
    while (!st.empty()){
        auto [c, v] = *st.rbegin();
        sz[v] = f;
        f++;
        st.erase(--st.end());
        for (auto x : g[v]){
            st.insert({a[x], x});
        }
    }
    if (fl){
        while (q--){
            int v;
            cin >> v;
            v--;
            cout << sz[v] << " ";
        }
    }
    else{
        int c1 = -1, c2 = -1;
        for (int i = 1; i < n; i++){
            if (par[i] == 0){
                if (c1 == -1){
                    c1 = i;
                }
                else{
                    c2 = i;
                }
            }
        }
        vector <int> w1;
        vector <int> w2;
        vector <int> color(n);
        w1.push_back(a[c1]);
        color[c1] = 1;
        while ((int)g[c1].size() > 0){
            c1 = g[c1][0];
            color[c1] = 1;
            w1.push_back(min(w1.back(), a[c1]));
        }
        w2.push_back(a[c2]);
        while ((int)g[c2].size() > 0){
            c2 = g[c2][0];
            w2.push_back(min(w2.back(), a[c2]));
        }
        for (int i =0; i < (int)w1.size(); i++){
            w1[i] *= -1;
        }
        for (int i =0; i < (int)w2.size(); i++){
            w2[i] *= -1;
        }
        vector <int> ans(n);
        for (int i = 1; i < n; i++){
            if (color[i] == 1){
                int cc = lower_bound(w2.begin(), w2.end(), -a[i]) - w2.begin();
                ans[i] = sz[i] - cc;
            }
            else{
                int cc = lower_bound(w1.begin(), w1.end(), -a[i]) - w1.begin();
                ans[i] = sz[i] - cc;
            }
        }
        while (q--){
            int v;
            cin >> v;
            v--;
            cout << ans[v] << " ";
        }
    }
}
