#include <bits/stdc++.h>

using namespace std;
#define int long long

vector<vector<int>> g;

vector<int> col, p;

void dfs(int v) {
    if (p[v] == 0) {
        col[v] = v;
    } else {
        col[v] = col[p[v]];
    }
    for (auto to: g[v]) {
        dfs(to);
    }
}

signed main() {
    int n, q;
    cin >> n >> q;
    p.resize(n);
    g.resize(n), col.resize(n);
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    vector<vector<int>> g1 = g;
    vector<int> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    dfs(0);
    vector<int> in(n), u(q);
    for (int i = 0; i < q; ++i) {
        cin >> u[i];
        in[u[i] - 1] = 1;
    }
    vector<int> an(n, 100000000);
    an[0] = 0;
    for (int bl = 1; bl < n; ++bl) {
        int curr = 0;
        set<pair<int, int>> sn;
        vector<int> cnt(n, 0), ans(n, n - 1);
        ans[0] = 1;
        g = g1;
        for (int i = 0; i < n - 1; ++i) {
            int ind = -1, mx = 0;
            for (auto to: g[curr]) {
                if (to == bl) {
                    continue;
                }
                if (s[to] > mx) {
                    mx = s[to];
                    ind = to;
                }
            }
            if (ind == -1) {
                break;
            }
            for (auto to: g[curr]) {
                if (to != ind) {
                    g[ind].push_back(to);
                }
            }
            curr = ind;
            ans[curr] = i + 1;
        }
        for (int i = 0; i < n; ++i) {
            an[i] = min(an[i], ans[i]);
        }
    }
    for (auto to: u) {
        cout << an[to - 1] << " ";
    }
    return 0;
}
