#include <bits/stdc++.h>

using ll = long long;
using ld = long double;

#define int ll
#define pii pair<int, int>
#define all(obj) obj.begin(), obj.end()
#define rall(obj) obj.rbegin(), obj.rend()
#define pb push_back

using namespace std;

const int INF = 1e9;

vector<vector<int>>g;

struct Node1 {
    int z, len, push1;
    Node1(): z(0), len(0), push1(0){}
};

int n;
vector<Node1>t1;

Node1 merge1(Node1 a, Node1 b) {
    Node1 res;
    res.z = a.z + b.z;
    res.len = a.len + b.len;
    return res;
}

void pull1(int v) {
    t1[v].z = t1[2*v].z + t1[2*v+1].z;
    t1[v].len = t1[2*v].len + t1[2*v+1].len;
}

void push1(int v) {
    if (t1[v].push1 != 0) {
        t1[2*v].z += t1[v].push1*t1[2*v].len;
        t1[2*v].push1 += t1[v].push1;
        t1[2*v+1].z += t1[v].push1*t1[2*v+1].len;
        t1[2*v+1].push1 += t1[v].push1;
        t1[v].push1 = 0;
    }
}

void build1 (vector<int>&a, int v, int tl, int tr) {
    if (tl == tr) {
        t1[v].z = a[tl];
        t1[v].len = 1;
        return;
    }
    int tm = (tl+tr)/2;
    build1(a, 2*v, tl, tm);
    build1(a, 2*v+1, tm+1, tr);
    pull1(v);
}

Node1 get1 (int v, int tl, int tr, int l, int r) {
    if (l > r) {
        return Node1();
    }
    if (l == tl && r == tr) {
        return t1[v];
    }

    push1(v);
    int tm = (tl+tr)/2;
    return merge1(get1(2*v, tl, tm, l, min(r, tm)), get1(2*v+1, tm+1, tr, max(l, tm+1), r));
}

int get1(int l, int r) {
    return get1(1, 0, 2*n, l, r).z;
}

void upd1(int v, int tl, int tr, int l, int r, int x) {
    if (l > r) {
        return;
    }
    if (l == tl && r == tr) {
        t1[v].z += t1[v].len*x;
        t1[v].push1 += x;
        return;
    }

    push1(v);
    int tm = (tl+tr)/2;
    upd1(2*v, tl, tm, l, min(r, tm), x);
    upd1(2*v+1, tm+1, tr, max(l, tm+1), r, x);
    pull1(v);
}

void upd1(int l, int r, int x) {
    upd1(1, 0, 2*n, l, r, x);
}


//------------------------------------------------------------------//

struct Node2 {
    int mx, len, push;
    Node2(): mx(-INF), len(0), push(0){}
};

vector<Node2>t2;

Node2 merge2(Node2 a, Node2 b) {
    Node2 res;
    res.mx = max(a.mx, b.mx);
    res.len = a.len + b.len;
    return res;
}

void pull2(int v) {
    t2[v].mx = max(t2[2*v].mx, t2[2*v+1].mx);
    t2[v].len = t2[2*v].len + t2[2*v+1].len;
}

void build2 (vector<int>&a, int v, int tl, int tr) {
    if (tl == tr) {
        t2[v].mx = a[tl];
        t2[v].len = 1;
        return;
    }
    int tm = (tl+tr)/2;
    build2(a, 2*v, tl, tm);
    build2(a, 2*v+1, tm+1, tr);
    pull2(v);
}

Node2 get2 (int v, int tl, int tr, int l, int r) {
    if (l > r) {
        return Node2();
    }
    if (l == tl && r == tr) {
        return t2[v];
    }

    int tm = (tl+tr)/2;
    return merge2(get2(2*v, tl, tm, l, min(r, tm)), get2(2*v+1, tm+1, tr, max(l, tm+1), r));
}

int get2(int l, int r) {
    return get2(1, 0, 2*n, l, r).mx;
}

void upd2(int v, int tl, int tr, int i, int x) {
    if (tl == i and tr == i) {
        t2[v].mx = x;
        return;
    }
    int tm = (tl+tr)/2;
    if (i <= tm) {
        upd2(2*v, tl, tm, i, x);
    }
    else {
        upd2(2*v+1, tm+1, tr, i, x);
    }
    pull2(v);
}

void upd2(int i, int x) {
    upd2(1, 0, 2*n, i, x);
}

//---------------------------------------------------

int timer = 0;
vector<int>tin, tout;
void dfs (int v, int p) {
    tin[v] = timer;
    timer++;
    for(auto u:g[v]) {
        if (u == p) continue;
        dfs(u, v);
    }
    timer++;
    tout[v] = timer;
}

signed main() {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int q;
    cin >> n >> q;
    g.resize(n);
    vector<int>pred(n);
    pred[0] = -1;
    for (int i=1; i<n; i++) {
        int p; cin >> p; p--;
        g[p].pb(i);
        g[i].pb(p);
        pred[i] = p;
    }
    vector<int>s(n);
    for (int i=0; i<n; i++) {
        cin >> s[i];
    }
    vector<int>Q(q);
    for (int i=0; i<q; i++) {
        cin >> Q[i];
        Q[i]--;
    }

    tin.resize(n);
    tout.resize(n);
    dfs(0, -1);

    
    vector<int>h(2*n+1, 0);
    t1.resize(4*h.size());
    build1(h, 1, 0, 2*n);
    t2.resize(4*h.size());
    build2(h, 1, 0, 2*n);

    vector<int>ans(n, 0);
    ans[0] = 0;

    set<pii>cur;
    for (auto i:g[0]) {
        cur.insert({-s[i], i});
    }

    vector<bool>used(n, false);
    used[0] = true;
    vector<int>last(n, -1);

    for (int day=1; day<n; day++) {
        if (day == 4) {
            int qqqqq = 0;
        }
        int v = cur.begin()->second;
        ans[v] = get2(tin[pred[v]], tout[pred[v]]) + 1;
        int can = INF;
        for(auto u:g[pred[v]]){
            if (u == pred[pred[v]] or u == v) continue;
            can = min(can, day - (get1(tin[u], tout[u])));
            
        }
        ans[v] = min(ans[v], can);

        last[pred[v]] = v;
        upd1(tin[v], tin[v], 1);
        upd2(tin[v], ans[v]);
        cur.erase(cur.begin());
        used[v] = true;
        for(auto u:g[v]) {
            if(!used[u]) {
                cur.insert({-s[u], u});
            }
        }
    }

    for (int i=0; i<q; i++) {
        cout << ans[Q[i]] << " ";
    }
}