#include <bits/stdc++.h>

using namespace std;

#define int long long

#define NEUTRAL_MOD 0

struct Segment_tree{
    struct Node{
        int l, r;
        int mx;
        Node() {}
        Node(int x, int ind) {
            l = ind;
            r = ind + 1;
            mx = x;
        }
        Node(Node le, Node ri) : l(le.l), r(ri.r) {
            mx = max(le.mx, ri.mx);
        }
    };
    vector<Node> tr;
    void build(int i, int l, int r, vector<int> &a) {
        if (r - l == 1) {
            tr[i] = Node(a[l], l);
            return;
        }
        int m = (l + r) / 2;
        build(2 * i + 1, l, m, a);
        build(2 * i + 2, m, r, a);
        tr[i] = Node(tr[2 * i + 1], tr[2 * i + 2]);
    }
    Node get(int l, int r, int i = 0) {
        if (l == r) return Node(0, 0);
        if (l <= tr[i].l && tr[i].r <= r) return tr[i];
        int m = (tr[i].l + tr[i].r) / 2;
        if (r <= m) return get(l, r, 2 * i + 1);
        if (m <= l) return get(l, r, 2 * i + 2);
        return Node(get(l, r, 2 * i + 1), get(l, r, 2 * i + 2));
    }
    void upd(int ind, int x, int i = 0) {
        if (tr[i].r <= ind || tr[i].l > ind) return;
        if (tr[i].r - tr[i].l == 1) {
            tr[i] = Node(max(x, tr[i].mx), ind);
            return;
        }
        upd(ind, x, 2 * i + 1);
        upd(ind, x, 2 * i + 2);
        tr[i] = Node(tr[2 * i + 1], tr[2 * i + 2]);
    }
    Segment_tree(vector<int> &a) {
        int n = a.size();
        tr.resize(4 * n);
        build(0, 0, n, a);
    }
    Segment_tree() {}
};

struct fenwick{
    vector<int> ans;
    fenwick(int n) {
        ans.resize(n + 1);
    }
    void add(int i, int x) {
        i++;
        while (i < ans.size()) {
            ans[i] += x;
            i += (i & (-i));
        }
    }
    int get(int i) {
        int fans = 0;
        while (i > 0) {
            fans += ans[i];
            i -= (i & (-i));
        }
        return fans;
    }
    fenwick() {}
};

vector<int> hld, hld_ind, p, uph, sz, heavy_ans, hld_end;// mxfi, mxsc;
vector<vector<int>> ch;
vector<set<pair<int, int>>> lans;

void dfs0(int i) {
    sz[i] = 1;
    heavy_ans[i] = 0;
    for (auto &j : ch[i]) {
        dfs0(j);
        lans[i].insert({0, j});
        sz[i] += sz[j];
    }
}

void build_hld(int i, int up_heavy) {
    for (int j = 1; j < ch[i].size(); j++) {
        if (sz[ch[i][j]] > sz[ch[i][0]]) swap(ch[i][j], ch[i][0]);
    }
    uph[i] = up_heavy;
    hld_ind[i] = hld.size();
    hld.push_back(i);
    if (ch[i].size() > 0) {
        build_hld(ch[i][0], up_heavy);
    }
    for (int j = 1; j < ch[i].size(); j++) {
        build_hld(ch[i][j], ch[i][j]);
    }
    hld_end[i] = hld.size();
} 

fenwick cnt1;
Segment_tree tr;

int get_sum(int i) {
    return cnt1.get(hld_end[i]) - cnt1.get(hld_ind[i]);
}

void upd_heavy(int i) {
    lans[i].erase({heavy_ans[i], ch[i][0]});
    heavy_ans[i] = get_sum(ch[i][0]);
    lans[i].insert({heavy_ans[i], ch[i][0]});
}

int get_light(int i) {
    upd_heavy(p[i]);
    if (prev(lans[p[i]].end())->second == i) {
        return prev(prev(lans[p[i]].end()))->first;
    } else {
        return prev(lans[p[i]].end())->first;
    }
}

void upd_light(int i) {
    int llans = get_sum(i);
    lans[p[i]].erase({llans - 1, i});
    lans[p[i]].insert({llans, i});
    tr.upd(hld_ind[p[i]], llans);
}

void set1(int i) {
    cnt1.add(hld_ind[i], 1);
    while (i > 0) {
        i = uph[i];
        if (i == 0) break;
        upd_light(i);
        i = p[i];
    }
}

int get(int i) {
    int ans = 0;
    while (i > 0) {
        ans = max(ans, tr.get(hld_ind[uph[i]], hld_ind[i]).mx);
        i = uph[i];
        if (i == 0) break;
        ans = max(ans, get_light(i));
        i = p[i];
    }
    return ans;
}

main() {
    int n, q;
    cin >> n >> q;
    hld_ind.resize(n);
    p.resize(n);
    uph.resize(n);
    sz.resize(n);
    heavy_ans.resize(n);
    hld_end.resize(n);
    ch.resize(n);
    lans.resize(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        ch[p[i]].push_back(i);
    }
    vector<pair<int, int>> s;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        s.push_back({tmp, i});
    }
    vector<int> f_ans(n);
    set<pair<int, int>> setik;
    setik.insert({-s[0].first, 0});
    int cur = 0;
    while (setik.size() > 0) {
        f_ans[(setik.begin())->second] = cur;
        cur++;
        int j = (setik.begin())->second;
        setik.erase(setik.begin());
        for (auto &i : ch[j]) {
            setik.insert({-s[i].first, i});
        }
    }
    for (int i = 0; i < n; i++) {
        s[i] = {f_ans[i], i};
    }
    cnt1 = fenwick(n);
    dfs0(0);
    build_hld(0, 0);
    tr = Segment_tree(heavy_ans);
    sort(s.begin(), s.end());
    for (auto &i : s) {
        f_ans[i.second] -= get(i.second);
        set1(i.second);
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        cout << f_ans[v] << " ";
    }
    cout << "\n";
}