#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2010;
const int INF = 1e9;
vector <int> g[N];
void solve(){
    int n, q;
    cin >> n >> q;
    vector <int> p(n);
    for (int i = 1; i < n; ++i){
        cin >> p[i];
        --p[i];
        g[p[i]].push_back(i);
    }
    vector <int> s(n);
    for (int i = 0; i < n; ++i){
        cin >> s[i];
    }
   // if (n <= 50 && q <= 50){
        vector <int> ans(n, INF);
        for (int i = 0; i < n; ++i){
            int canc = s[i];
            s[i] = 0;
            int cnt = 0;
            set <pair <int, int>> st;
            st.insert({s[0], 0});
            while (!st.empty()){
                auto cur = *--st.end();
                st.erase(cur);
                ans[cur.second] = min(ans[cur.second], cnt);
                cnt++;
                for (auto to: g[cur.second]){
                    st.insert({s[to], to});
                }
            }
            s[i] = canc;
        }
   // }
    /*vector <int> ans(n);
    ans[0] = 0;
    for (int i = 1; i < n; ++i){
        ans[i] = ans[p[i]] + 1;
    }*/
    while (q--){
        int v;
        cin >> v;
        --v;
        cout << ans[v] << " ";
    }

}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
   // cin >> t;
    while (t--){
        solve();
        cout << "\n";
    }
}




