#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<vector<int>> graph(n);
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        graph[--p].push_back(i);
    }
    vector<int> s(n), ans(n, 1e9);
    for (auto &elem : s) cin >> elem;
    set<pair<int, int>> st;
    for (int bad = 0; bad < n; bad++) {
        int was = s[bad];
        s[bad] = 0;
        st = {{s[0], 0}};
        int counter = 0;
        while (!st.empty()) {
            int cur = st.rbegin()->second;
            if (cur == bad) break;
            ans[cur] = min(ans[cur], counter++);
            st.erase(prev(st.end()));
            for (auto elem : graph[cur]) {
                st.insert({s[elem], elem});
            }
        }
        s[bad] = was;
    }
    while (q--) {
        int v;
        cin >> v;
        cout << ans[--v] << '\n';
    }
}
