#include <bits/stdc++.h>

using namespace std;

int n;
vector<vector<int> > g;
vector<int> p;
vector<int> s;
vector<int> v;

class Compare{
public:
    bool operator() (int a, int b) const{
        return s[a] < s[b];
    }
};

int cancelled = 0;

vector<vector<int> > precalc;
vector<int> seq;

void bfs(int v){
    priority_queue<int, vector<int>, Compare> pq;
    int buf = s[v];
    s[v] = 0;
    pq.push(1);

    int t = 0;
    while (!pq.empty()){
        int u = pq.top(); pq.pop();
        //cout << "bfs " << v << " " << u << endl;
        if (v == 0)
            seq.push_back(u);
        precalc[v][u] = t++;
        for (int other : g[u]){
            pq.push(other);
        }
    }

    s[v] = buf;
}

vector<int> dp;
vector<int> tin, tout;

int t = 0;

void dfs(int v){
    tin[v] = t++;
    for (int other : g[v])
        dfs(other);
    tout[v] = t++;
}

bool is_anc(int v, int u){
    return tin[v] <= tin[u] && tout[u] <= tout[v];
}

int main()
{
    int n, q; cin >> n >> q;
    g.resize(n + 1);
    p.resize(n + 1);
    s.resize(n + 1);

    for (int i = 2; i <= n; ++i){
        cin >> p[i];
        g[p[i]].push_back(i);
    }

    /*for (int i = 1; i <= n; ++i){
        cout << "ch of " << i << ":   ";
        for (int other : g[i])
            cout << other << " ";
        cout << endl;
    }*/

    for (int i = 1; i <= n; ++i)
        cin >> s[i];

    precalc.resize(1, vector<int>(n + 1, n + 1));

    /*for (int i = 0; i <= n; ++i)
        bfs(i);*/

    /*for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= n; ++j){
            cout << setw(3) << precalc[i][j];
        }
        cout << endl;
    }
    cout << endl;*/

    bfs(0);

    /*cout << "seq   ";
    for (int i = 0; i < n; ++i)
        cout << seq[i] << " ";
    cout << endl;*/

    tin.resize(n + 1);
    tout.resize(n + 1);
    dfs(1);

    /*cout << "tin   ";
    for (int i = 1; i <= n; ++i)
        cout << tin[i] << " ";
    cout << endl;
    cout << "tout   ";
    for (int i = 1; i <= n; ++i)
        cout << tout[i] << " ";
    cout << endl;*/

    int best_ch1 = 0, best_ch2 = 0;
    for (int other : g[1]){
        if (s[other] > s[best_ch1]){
            best_ch2 = best_ch1;
            best_ch1 = other;
        }
        else if (s[other] > s[best_ch2]){
            best_ch2 = other;
        }
    }

    //cout << "best_ch_1 = " << best_ch1 << endl;
    //cout << "best_ch_2 = " << best_ch2 << endl;

    //cout << is_anc(1, 8) << endl;

    dp.resize(n + 1);

    int ch_of_best1 = 0;
    int ch_of_best2 = 0;
    for (int i = 0; i < n; ++i){
        if (is_anc(best_ch1, seq[i])){
            //cout << seq[i] << ":    " << i << " - " << ch_of_best2 << endl;
            //cout << seq[i] << " child of best1 " << best_ch1 << endl;
            dp[seq[i]] = i - ch_of_best2;
            ++ch_of_best1;
        }
        else{
            //cout << seq[i] << ":    " << i << " - " << ch_of_best1 << endl;
            dp[seq[i]] = i - ch_of_best1;
            if (is_anc(best_ch2, seq[i])){
                //cout << seq[i] << " child of best2 " << best_ch2 << endl;
                ++ch_of_best2;
            }
        }
    }

    v.resize(q);
    for (int i = 0; i < q; ++i){
        cin >> v[i];

        /*int ans = precalc[0][v[i]];
        for (int j = 1; j <= n; ++j){
            ans = min(ans, precalc[j][v[i]]);
        }
        cout << ans << " ";*/

        cout << dp[v[i]] << " ";
    }
    cout << endl;

    return 0;
}


/*
6 6
1 1 2 2 5
1 2 3 4 5 6
1 2 3 4 5 6

8 8
1 2 1 4 1 6 7
5 6 4 2 1 8 5 3
1 2 3 4 5 6 7 8

*/
