#include <bits/stdc++.h>

using namespace std;

vector<int> p, val, prior, tin, tout, st, d;
vector<vector<int>> v, tree;
int tt = 0, n, res = 0;

void make_tree(int x, int l, int r) {
    if (r - l == 1) {
        tree[x] = {prior[st[l]]};
        return;
    }
    int m = (l + r) / 2;
    make_tree(2 * x + 1, l, m);
    make_tree(2 * x + 2, m, r);
    int id1 = 0, id2 = 0;
    while (id1 != m - l && id2 != r - m) {
        if (tree[2 * x + 1][id1] < tree[2 * x + 2][id2]) {
            tree[x].push_back(tree[2 * x + 1][id1]);
            id1++;
        } else {
            tree[x].push_back(tree[2 * x + 2][id2]);
            id2++;
        }
    }
    while (id1 != m - l) {
        tree[x].push_back(tree[2 * x + 1][id1]);
        id1++;
    }
    while (id2 != r - m) {
        tree[x].push_back(tree[2 * x + 2][id2]);
        id2++;
    }
}

int find_ans(int x, int l, int r, int ql, int qr, int val) {
    if (ql == l && qr == r) {
        return upper_bound(tree[x].begin(), tree[x].end(), val) - tree[x].begin();
    }
    int m = ( r + l) / 2;
    if (qr <= m) {
        return find_ans(2 * x + 1, l, m, ql, qr, val);
    }
    if (ql >= m) {
        return find_ans(2 * x + 2, m, r, ql, qr, val);
    }
    return find_ans(2 * x + 1, l, m, ql, m, val) + find_ans(2 * x + 2, m, r, m, qr, val);
}


void dfs(int x) {
    st.push_back(x);
    tin[x] = tt++;
    for (auto j : v[x]) {
        d[j] = d[x] + 1;
        dfs(j);
    }
    tout[x] = tt;
}

bool is_p(int x, int y) {
    if (tin[x] <= tin[y] && tout[x] >= tout[y]) {
        return true;
    }
    return false;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int q;
    cin >> n >> q;
    tree.resize(4 * n);
    prior.resize(n);
    v.resize(n);
    d.resize(n);
    val.resize(n);
    tin.resize(n);
    tout.resize(n);
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        x--;
        v[x].push_back(i);
    }

    dfs(0);
    for (int i = 0; i < n; i++) {
        cin >> val[i];
    }
    set<pair<int, int>> s;
    s.insert({val[0], 0});
    while (!s.empty()) {
        auto it = s.end();
        it--;
        auto [val1, id1] = *it;
        s.erase(it);
        prior[id1] = p.size();
        p.push_back(id1);
        for (auto j : v[id1]) {
            s.insert({val[j], j});
        }
    }
    make_tree(0, 0, n);
    if (n * q <= 1000000) {
    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        x--;
        res = 0;
        for (int j = 0; j < n; j++) {
            if (!is_p(j, x)) {
                res = max(res, find_ans(0, 0, n, tin[j], tout[j], prior[x]));
            }
        }
        cout << prior[x] - res << ' ';
    }
    } else {
        for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        x--;
        cout << d[x] << ' ';
    }
    }
}
