#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 = 3e5;

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

struct SegmentTree {
    struct node {
        int max = 0, ver = 0;

        node() = default;

        node(int _max, int _ver) : max(_max), ver(_ver) {}

        bool operator<(const node &other) const {
            return max < other.max;
        }
    };

    std::array<node, 4 * N> t;

    void update(int v, int l, int r, int i, int val, int ver) {
        if (l + 1 == r) {
            t[v] = {val, ver};
            return;
        }
        int m = (r + l) / 2;
        if (i < m) {
            update(2 * v, l, m, i, val, ver);
        } else {
            update(2 * v + 1, m, r, i, val, ver);
        }
        t[v] = std::max(t[2 * v], t[2 * v + 1]);
    }
};

SegmentTree t;

struct dsu {
    int mx = 0;
    std::array<int, N> p{}, sz{};

    void build(int n) {
        std::iota(p.begin(), p.begin() + n, 0);
        std::fill_n(sz.begin(), n, 1);
        sz[0] = 0;
    }

    int find(int x) {
        return p[x] == x ? x : p[x] = find(p[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return;
        }
        if (sz[x] < sz[y]) {
            std::swap(x, y);
        }
        sz[x] += sz[y];
        p[y] = x;
        mx = std::max(mx, sz[x]);
    }
};

dsu d;

void dfs(int v) {
    tin[v] = timer++;
    ans[v] = tin[v] - d.mx;
    for (auto &to: g[v]) {
        dfs(to);
    }
    for (auto &to: g[v]) {
        d.unite(v, to);
    }
}

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];
    }
    int sz = 1;
    for (auto &to: g[0]) {
        wh[to] = sz++;
        t.update(1, 0, n, wh[to], s[to], to);
    }
    for (int i = 1; i < n; ++i) {
        int who = t.t[1].ver;
        indx[who] = i;
        t.update(1, 0, n, wh[who], 0, 0);
        for (auto &to: g[who]) {
            wh[to] = sz++;
            t.update(1, 0, n, wh[to], s[to], to);
        }
    }
    for (int i = 0; i < n; ++i) {
        std::ranges::sort(g[i], [&](int x, int y) {
            return indx[x] < indx[y];
        });
    }
    d.build(n);
    dfs(0);
    for (int i = 0; i < q; ++i) {
        int v;
        std::cin >> v;
        --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;
}