#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 3e5 + 7;

vector <int> v[N];
int c[N];
int ans[N];


signed main() {
    int n, q;
    cin >> n >> q;
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        v[p].push_back(i);
    }
    //cout << "HERE" << endl;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < n; i++) {
        ans[i] = N;
    }
    for (int i = 0; i < n; i++) {
        int zn = 0;
        int C = c[i];
        c[i] = 0;
        set <pair <int, int>> st;
        st.insert({c[0], 0});
        while (!st.empty()) {
            auto [c1, pos] = *st.rbegin();
            ans[pos] = min(ans[pos], zn);
            zn++;
            st.erase({c1, pos});
            for (auto u: v[pos]) {
                st.insert({c[u], u});
            }
        }
        c[i] = C;
    }
    //cout << "HERE" << endl;
    vector <int> ans1;
    while (q--) {
        int x;
        cin >> x;
        ans1.push_back(ans[x - 1]);
    }
    for (auto u: ans1) {
        cout << u << " ";
    }
}

