//I wrote this code 4 u <3
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

template<typename T> using normal_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 0x3f3f3f3f;

struct BIT {
    vector<int> t;
    int sz;

    BIT(int n) : t(n + 1), sz(n) {}

    void upd(int i, int v) {
        for (++i; i <= sz; i += i & -i) {
            t[i] += v;
        }
    }

    int get(int r) {
        int res = 0;
        for (; r > 0; r -= r & -r) res += t[r];
        return res;
    }

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

signed main(int32_t argc, char* argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    for (int i = 1; i < n; ++i) {
        int x;
        cin >> x;
        g[x - 1].push_back(i);
    }
    vector<int> s(n), ans(n, inf);
    for (auto& x : s) cin >> x;
    vector<int> ord;
    priority_queue<pair<int, int>> pq;
    pq.push({s[0], 0});
    vector<int> tm(n);
    while (!pq.empty()) {
        auto [_, v] = pq.top(); pq.pop();
        tm[v] = (int) ord.size();
        ord.push_back(v);
        for (auto to : g[v]) {
            pq.push({s[to], to});
        }
    }
    int T = 0;
    vector<int> tin(n), tout(n);
    auto Dfs = [&](auto&& self, int u) -> void {
        tin[u] = T++;
        for (auto to : g[u]) {
            self(self, to);
        }
        tout[u] = T;
    };
    Dfs(Dfs, 0);
    auto isp = [&](int p, int v) {
        return tin[p] <= tin[v] && tout[v] <= tout[p];
    };
    while (q--) {
        int x;
        cin >> x; --x;
        int ans = tm[x];
        BIT tt(n);
        for (int i = 0; i < tm[x]; ++i) {
            int v = ord[i];
            tt.upd(tin[v], 1);
        }
        for (int i = 0; i < n; ++i) {
            if (isp(i, x)) continue;
            ans = min(ans, tm[x] - tt.get(tin[i], tout[i]));
        }
        cout << ans << ' ';
    }
}

/*

*/