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

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

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

    p[v] = buf;
}

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(n + 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;*/

    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 << endl;

    return 0;
}


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