#include <bits/stdc++.h>
#include <bits/extc++.h>

#ifndef LOCAL
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma GCC optimize("unrool-looops")
#endif

std::random_device rd;
std::mt19937_64 gen(rd());

using namespace __gnu_pbds;
using ll = long long;

template<class T>
using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e3;

std::array<int, N> s, ans, indx, tin, tout;
std::array<std::vector<int>, N> g;
int timer = 0;

void calc(int v) {
    tin[v] = timer++;
    for (auto &to: g[v]) {
        calc(to);
    }
    tout[v] = timer++;
}

bool parent(int v, int u) { // v -> ... -> u
    return tin[v] <= tin[u] && tin[u] < tout[v];
}

int dfs(int v, int first) {
    int sz = 1, mx = 0;
    for (auto &to: g[v]) {
        if (parent(to, first)) {
            continue;
        }
        if (indx[to] < indx[first]) {
            if (v != 0) {
                sz += dfs(to, first);
            } else {
                mx = std::max(mx, dfs(to, first));
            }
        }
    }
    if (v != 0) {
        return sz;
    }
    return mx;
}

void not_main() {
    int n, q;
    std::cin >> n >> q;
    for (int i = 1; i < n; ++i) {
        int p;
        std::cin >> p;
        --p;
        g[p].emplace_back(i);
    }
    for (int i = 0; i < n; ++i) {
        std::cin >> s[i];
    }
    calc(0);
    std::vector<int> children = g[0];
    for (int i = 1; i < n; ++i) {
        int max = 0, who = -1;
        for (auto &c: children) {
            if (max < s[c]) {
                max = s[c];
                who = c;
            }
        }
        indx[who] = i;
        children.erase(std::ranges::find(children, who));
        for (auto &to: g[who]) {
            children.emplace_back(to);
        }
    }
    ans.fill(-1);
    ans[0] = 0;
    for (int i = 0; i < q; ++i) {
        int v;
        std::cin >> v;
        --v;
        if (ans[v] != -1) {
            std::cout << ans[v] << ' ';
            continue;
        }
        ans[v] = indx[v] - dfs(0, v);
        std::cout << ans[v] << ' ';
    }
    std::cout << '\n';
}

signed main() {
    std::ios_base::sync_with_stdio(false);
#ifndef LOCAL
    std::cin.tie(nullptr);
#endif
    int tests = 1;
    // std::cin >> tests;
    while (tests--) {
        not_main();
    }
    return 0;
}