//#pragma GCC optimize("O2")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target("popcnt") 1's count

#include <vector>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <unordered_set>
#include <climits> //INT_MAX, LLONG_MAX
#include <random> //mt19937
#include <numeric> //gcd
#include <bitset>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using db = double;
//#define int long long

constexpr ll inf = 2e18;

vector <vector <int>> g, qs;
vector <int> s, t, tin, tout, ans, p;
vector <set <pair <int, int>>> gs;
int ptr = 0;

void dfs(int v) {
    tin[v] = ptr++;
    for (int to : g[v]) {
        gs[v].insert({-s[to], to});
        dfs(to);
    }
    tout[v] = ptr;
}

int get(int v, int vl, int vr, int ql, int qr) {
    if (vl == ql && vr == qr) {
        return t[v];
    }
    int vm = (vl + vr) / 2;
    if (qr <= vm) {
        return get(2 * v, vl, vm, ql, qr);
    }
    if (ql >= vm) {
        return get(2 * v + 1, vm, vr, ql, qr);
    }
    return get(2 * v, vl, vm, ql, vm) + get(2 * v + 1, vm, vr, vm, qr);
}

void upd(int v, int vl, int vr, int pos) {
    if (vl + 1 == vr) {
        t[v]++;
        return;
    }
    int vm = (vl + vr) / 2;
    if (pos < vm) {
        upd(2 * v, vl, vm, pos);
    } else {
        upd(2 * v + 1, vm, vr, pos);
    }
    t[v] = t[2 * v] + t[2 * v + 1];
}

void sol() {
    int n, q, x;
    cin >> n >> q;
    g.resize(n), s.resize(n), tin.resize(n), tout.resize(n);
    t.resize(4 * n), ans.resize(q), qs.resize(n), p.resize(n);
    gs.resize(n);
    p[0] = -1;
    for (int i = 1; i < n; i++) {
        cin >> x;
        x--;
        p[i] = x;
        g[x].push_back(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    dfs(0);
    for (int i = 0; i < q; i++) {
        cin >> x;
        x--;
        qs[x].push_back(i);
    }
    int cur = 0;
    set <pair <int, int>> scur = gs[0];
    for (int i = 0; i < n; i++) {
        for (int num : qs[cur]) {
            int cnt = 0;
            ans[num] = i;
            for (int temp = p[cur]; temp != -1; temp = p[temp]) {
                ans[num] = min(ans[num], i - (get(1, 0, n, tin[temp], tout[temp]) - 1 - cnt));
                cnt = get(1, 0, n, tin[temp], tout[temp]);
            }
        }
        if (i == n - 1) {
            break;
        }
        upd(1, 0, n, tin[cur]);
        int nxt = scur.begin()->second;
        scur.erase(scur.begin());
        if (gs[nxt].size() >= scur.size()) {
            swap(scur, gs[nxt]);
        }
        //TODO
        scur.insert(gs[nxt].begin(), gs[nxt].end());
        //TODO
        cur = nxt;
    }

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

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    cout.precision(15);

    int T = 1;
    //cin >> T;
    while (T--) {
        sol();
    }
}

//5 4
//1 2 2 1
//3 5 1 2 4
//5 3 1 4