#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using pair = std::pair<long long, long long>;
struct segtree {
    long long lb, rb;
    segtree *l = nullptr;
    segtree *r = nullptr;
    long long max = 0;
    segtree(long long lq, long long rq) {
        lb = lq;
        rb = rq;
        if(rb - lb > 1) {
            long long mb = (lb + rb) / 2;
            l = new segtree(lb, mb);
            r = new segtree(mb, rb);
        }
    }
    long long getMax(long long lq, long long rq) {
        if(lq >= rb || lb >= rq) {
            return 0;
        }
        if(lq <= lb && rb <= rq) {
            return max;
        }
        return std::max(l->getMax(lq, rq), r->getMax(lq, rq));
    }
    void pointAdd(long long k) {
        if(l) {
            if(k < l->rb) {
                l->pointAdd(k);
            } else {
                r->pointAdd(k);
            }
            max = std::max(l->max, r->max);
        } else {
            ++max;
        }
    }
};
int main() {
    std::cin.tie(0);
    std::cout.tie(0);
    std::cin.sync_with_stdio(false);
    long long n, q, i, v;
    std::cin >> n >> q;
    std::vector<long long> p(n + 1);
    std::vector<std::vector<long long>> g(n + 1);
    for(i = 2; i <= n; ++i) {
        std::cin >> p[i];
        g[p[i]].push_back(i);
    }
    std::vector<long long> s(n + 1);
    for(i = 1; i <= n; ++i) {
        std::cin >> s[i];
    }
    std::priority_queue<pair> queue;
    queue.push(pair{s[1], 1});
    std::vector<long long> pos(n + 1);
    std::vector<long long> indexes;
    while(!queue.empty()) {
        auto [w, v] = queue.top();
        queue.pop();
        pos[v] = indexes.size();
        indexes.push_back(v);
        for(long long u : g[v]) {
            queue.push(pair{s[u], u});
        }
    }
    std::vector<long long> ans(n + 1, 0);
    std::vector<long long> query(q);
    for(i = 0; i < q; ++i) {
        std::cin >> query[i];
    }
    
    std::vector<long long> secondary;
    for(i = 2; i <= n; ++i) {
        if(p[i] == 1) {
            secondary.push_back(i);
        }
    }
    long long secondaryCount = secondary.size();
    std::vector<long long> secondaryPredokIndex(n + 1, 0);
    for(i = 0; i < secondary.size(); ++i) {
        v = secondary[i];
        secondaryPredokIndex[v] = i + 1;
    }
    for(i = 2; i <= n; ++i) {
        if(secondaryPredokIndex[i] == 0) {
            secondaryPredokIndex[i] = secondaryPredokIndex[p[i]];
        }
    }
    for(i = 2; i <= n; ++i) {
        --secondaryPredokIndex[i];
    }
    long long curSecondaryIndex;
    segtree tree(0, secondaryCount);
    for(i = 1; i < n; ++i) {
        v = indexes[i];
        curSecondaryIndex = secondaryPredokIndex[v];
        long long maxMinusLeft = 0;
        if(curSecondaryIndex > 0) {
            maxMinusLeft = tree.getMax(0, curSecondaryIndex);
        }
        long long maxMinusRight = 0;
        if(curSecondaryIndex + 1 < secondaryCount) {
            maxMinusRight = tree.getMax(curSecondaryIndex + 1, secondaryCount);
        }
        long long maxMinus = std::max(maxMinusLeft, maxMinusRight);
        ans[v] = i - maxMinus;
        tree.pointAdd(curSecondaryIndex);
    }

    for(i = 0; i < q; ++i) {
        if(i) std::cout << ' ';
        std::cout << ans[query[i]];
    }
    std::cout << '\n';
}