#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
#ifdef home
    freopen("f.in", "r", stdin);
    freopen("f.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    for (int v = 1; v < n; v++) {
        int u;
        cin >> u;
        u--;
        g[u].emplace_back(v);
    }
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    vector<int> ans(n + 1, n + 1);
    for (int i = 0; i < n; i++) {
        int was = 0;
        swap(was, s[i]);
        set<pair<int, int>> flex;
        for (auto &v: g[0]) {
            flex.emplace(s[v], v);
        }
        for (int root = 0, epoch = 0; root != -1; epoch++) {
            ans[root] = min(ans[root], epoch);
            if (flex.empty()) {
                break;
            }
            int cand = flex.rbegin()->second;
            flex.erase(*flex.rbegin());
            for (auto &v: g[cand]) {
                flex.emplace(s[v], v);
            }
            swap(cand, root);
        }
        swap(was, s[i]);
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        cout << ans[v] << ' ';
    }
    cout << '\n';
    return 0;
}
