#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        g[p - 1].push_back(i);
    }
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int cur = 0;
    vector<int> best(n, n);
    best[0] = 0;
    for (int j = 0; j < n; j++) {
        cur = 0;
        vector<vector<int>> g_new = g;
        int was = s[j];
        s[j] = 0;
        for (int i = 0; i < n - 1; i++) {
            int mx = 0, new_cur = -1;
            for (auto el: g_new[cur]) {
                mx = max(mx, s[el]);
                if (mx == s[el]) {
                    new_cur = el;
                }
            }
            for (auto el: g_new[cur]) {
                if (el != new_cur) {
                    g_new[new_cur].push_back(el);
                }
            }
            best[new_cur] = min(best[new_cur], i + 1);
            cur = new_cur;
        }
        s[j] = was;
    }
    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        cout << best[x - 1] << " ";
    }
}
