#include <bits/extc++.h>
#define int long long
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;

const int inf = 2e9;
vector<vector<pair<int, int>>> g;
vector<int> t, tin, tout; int TM = 0;
void dfs(int v) {
    tin[v] = TM++;
    for (auto [f, u]: g[v]) {
        dfs(u);
    }
    tout[v] = TM;
}

struct segtree {
    vector<vector<int>> node;
    int n;
    
    segtree () {};

    segtree(int _n) {
        n = _n;
        node.resize(4 * n);
        build(0, 0, n);
    }

    void build(int v, int l, int r) {
        if (l + 1 == r) {
            node[v].push_back(t[tin[l]]);
        } else {
            int m = (l + r) / 2;
            build(2 * v + 1, l, m);
            build(2 * v + 2, m, r);
            std::merge(all(node[2 * v + 1]), all(node[2 * v + 2]), std::back_inserter(node[v]));
        }
    }

    int query(int v, int l, int r, int ql, int qr, int x) {
        if (ql <= l && r <= qr) {
            return lower_bound(all(node[v]), x) - node[v].begin();
        } else if (r <= ql || qr <= l) {
            return 0;
        } else {
            int m = (l + r) / 2;
            return query(2 * v + 1, l, m, ql, qr, x) + query(2 * v + 2, m, r, ql, qr, x);
        }
    }

    int query(int l, int r, int x) {
        return query(0, 0, n, l, r, x);
    }
};

segtree st;

int get(int v, int x) {
    return st.query(tin[v], tout[v], x);
}

void solve() {
    int n, k; cin >> n >> k;
    vector<int> p(n, -1), s(n);
    g.resize(n);
    for (int i = 1; i < n; ++i) {
        cin >> p[i]; --p[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        if (i != 0) {
            g[p[i]].push_back({-s[i], i});
        }
    }
    for (int i = 0; i < n; ++i) {
        sort(g[i].begin(), g[i].end());
    }
    tin.resize(n);
    tout.resize(n);
    dfs(0);
    t.resize(n, inf);
    set<pair<int, int>> q;
    q.insert({s[0], 0});
    for (int i = 0; !q.empty(); ++i) {
        int v = q.begin()->second;
        q.erase(q.begin());
        t[v] = min(t[v], i);
        for (auto [f, u]: g[v]) {
            q.insert({f, u});
        }
    }
    st = segtree(n);
    for (int it = 0; it < k; ++it) {
        int v; cin >> v; --v;
        int vog = v;
        int cur = p[v];
        int ans = t[v];
        while (cur != -1) {
            int mx = 0;
            for (auto [f, u]: g[cur]) {
                if (u != v) {
                    mx = max(mx, get(u, t[vog]));
                }
            }
            ans = min(ans, t[vog] - mx);
            v = cur;
            cur = p[cur];
        }
        cout << ans << ' ';
    }
    cout << '\n';
}

signed main(void) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
}

/*
8 8
1 1 1 1 1 1 1
2 5 4 3 1 8 7 6            
1 2 3 4 5 6 7 8
*/