#include <bits/stdc++.h>

using namespace std;

#define int long long

int INF = 1e17;
vector<vector<int>> g;

int get(vector<int>& s, int v) {
    set<pair<int, int>> mai;
    mai.insert({-s[0], 0});
    int ans = 0;
    while (mai.begin()->second != v) {
        ans++;
        int u = mai.begin()->second;
        mai.erase(mai.begin());
        for (auto to : g[u]) {
            mai.insert({-s[to], to});
        }
    }
    return ans;
}

void sovel() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    vector<int> s(n);
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }
    for (auto& to : s) cin >> to;
    while (q--) {
        int v;
        cin >> v;
        v--;
        int ans = INF;
        for (int i = 0; i < n; i++) {
            auto val = s[i];
            s[i] = 0;
            ans = min(ans, get(s, v));
            s[i] = val;
        }
        cout << ans << " ";
    }
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        sovel();
    }
}
