#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

typedef long long ll;

const int LG = 20;

struct Fenwick {
    vector<int> f;

    Fenwick(int n) : f(n + 1) {}

    void add(int p, int x) {
        while (p < (int) f.size()) {
            f[p] += x;
            p += p & -p;
        }
    }

    int get(int p) {
        int ans = 0;
        while (p > 0) {
            ans += f[p];
            p -= p & -p;
        }
        return ans;
    }

    int get_on_segment(int l, int r) {
        return get(r) - get(l);
    }
};

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    vector<int> pred(n);
    for (int v = 1; v < n; ++v) {
        int p;
        cin >> p;
        p--;
        g[p].emplace_back(v);
        pred[v] = p;
    }
    vector<int> a(n);
    for (auto &i : a) {
        cin >> i;
    }
    vector<int> query(q), want(n);
    for (int &v : query) {
        cin >> v;
        v--;
        want[v] = 1;
    }

    vector<vector<int>> binUp(LG, vector<int> (n));
    vector<int> euler, tin(n), tout(n), deep(n);
    auto dfs = [&] (auto &&self, int v) -> void {
        tin[v] = (int) euler.size();
        euler.emplace_back(v);
        binUp[0][v] = pred[v];
        for (int lg = 1; lg < LG; ++lg) {
            binUp[lg][v] = binUp[lg - 1][binUp[lg - 1][v]];
        }
        for (int u : g[v]) {
            deep[u] = deep[v] + 1;
            self(self, u);
        }
        tout[v] = (int) euler.size();
    };
    dfs(dfs, 0);

    auto is_ancestor = [&] (int v, int u) -> bool {
        return v != n && tin[v] <= tin[u] && tout[u] <= tout[v];
    };

    set<pair<int, int>> st;
    st.insert({-a[0], 0});
    vector<int> fact(n), ans(n), mx1(n, n), mx2(n, n), sz(n + 1);
    int time = 0;
    Fenwick f(n);
    vector<int> d;
    while (!st.empty()) {
        auto [val, v] = *st.begin();
        st.erase(st.begin());
        fact[v] = ans[v] = time++;
        if (want[v]) {
            int p = v;
            while (p != 0) {
                p = pred[p];
                int x = sz[mx1[p]];
                if (is_ancestor(mx1[p], v)) {
                    x = sz[mx2[p]];
                }
                ans[v] = min(ans[v], fact[v] - x);
            }
        }
        //cout << v << endl;
        int p = v;
        sz[v]++;
        while (p != 0) {
            int u = p;
            p = pred[p];
            sz[p]++;
            if (mx1[p] != u && sz[mx1[p]] <= sz[u]) {
                mx2[p] = mx1[p];
                mx1[p] = u;
            } else if (mx2[p] != u && sz[mx2[p]] < sz[u]) {
                mx2[p] = u;
            }
        }
        //cout << v << ' ' << fact[v] << ' ' << ans[v] << endl;

        d.emplace_back(v);
        f.add(tin[v] + 1, 1);
        for (int u : g[v]) {
            st.insert({-a[u], u});
        }
        /*for (int u = 0; u < n; ++u) {
            cout << mx1[u] << ',' << mx2[u] << ' ';
        }
        cout << '\n';*/
    }

    for (auto v : query) {
        cout << ans[v] << ' ';
    }
    cout << '\n';
    return 0;
}
