#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, q; cin >> n >> q;
    vector<int> p(n); p[0] = -1;
    for (int i = 1; i < n; ++i) cin >> p[i];
    for (int i = 1; i < n; ++i) p[i]--;
    vector<int> s(n);
    for (int i = 0; i < n; ++i) cin >> s[i];
    while (q--){
        int u; cin >> u; u--;
        int ans = n + 10;
        for (int qa = 0; qa < n; ++qa){
            vector<int> pp = p;
            int sohr = s[qa]; s[qa] = 0;
            int nach = 0, dn = 0;
            while (nach != u){
                dn++;
                int luch = -1;
                for (int i = 0; i < n; ++i) if (p[i] == nach) if (luch == -1 || s[luch] < s[i]) luch = i;
                p[luch] = -1;
                for (int i = 0; i < n; ++i) if (p[i] == nach) p[i] = luch;
                nach = luch;
            }
            ans = min(ans, dn);
            p = pp; s[qa] = sohr;
        }
        cout << ans << " ";
    }
}
