#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 get_lca = [&] (int v, int u) -> int {
        bool s = false;
        if (deep[v] < deep[u]) {
            s = true;
            swap(v, u);
        }
        for (int lg = LG - 1; lg >= 0; --lg) {
            if (deep[binUp[lg][v]] >= deep[u]) {
                v = binUp[lg][v];
            }
        }
        for (int lg = LG - 1; lg >= 0; --lg) {
            if (binUp[lg][v] != binUp[lg][u]) {
                v = binUp[lg][v];
                u = binUp[lg][u];
            }
        }
        if (s) {
            return v;
        }
        return u;
    };

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

    set<pair<int, int>> st;
    st.insert({-a[0], 0});
    vector<int> fact(n), ans(n);
    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 (!d.empty() && want[v]) {
            for (int pst : d) {
                if (!is_ancestor(pst, v)) {
                    //int lca = get_lca(v, pst);
                    //cout << "! " << v << ' ' << pst << ' ' << lca << ' ' <<  f.get_on_segment(tin[lca], tout[lca]) << ' ' << fact[v] - f.get_on_segment(tin[lca], tout[lca]) << '\n';
                    ans[v] = min(ans[v], fact[v] - f.get_on_segment(tin[pst], tout[pst]));
                }
            }

        }
        //cout << v << ' ' << fact[v] << ' ' << ans[v] << '\n';

        d.emplace_back(v);
        f.add(tin[v] + 1, 1);
        for (int u : g[v]) {
            st.insert({-a[u], u});
        }
    }

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