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

const int maxn = 1e6;
vector<int> g[maxn];
int a[maxn], s[maxn], ans[maxn], p[maxn], sz[maxn];

vector<int> order;

void emulate(set<pair<int, int>> & st) {
    int nm = 0;
    while (!st.empty()) {
        auto [x, v] = *st.begin();
        ans[v] = min(ans[v], nm);
        for (auto u : g[v]) {
            st.insert({-s[u], u});
        }
        st.erase({x, v});
        order.push_back(v);
        nm++;
    }
    return;
}

pair<pair<int, int>, pair<int, int>> ans1[maxn];

int get(int v, int ban) {
    if (ans1[v].first.first == ban) {
        return ans1[v].second.second;
    }
    return ans1[v].first.second;
}

void update(int v, int newsz, int news) {
    if (ans1[v].first.first == news) {
        ans1[v].first.second = newsz;
        return;
    }
    if (ans1[v].second.first == news) {
        ans1[v].second.second = newsz;
        return;
    }
    if (newsz > ans1[v].first.second) {
        swap(ans1[v].first, ans1[v].second);
        ans1[v].first = {news, newsz};
        return;
    }
    if (newsz > ans1[v].second.second) {
        ans1[v].second = {news, newsz};
    }
}

void solve() {
    int n, q;
    cin >> n >> q;
    fill(ans, ans + n, 1e7);
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x; x--;
        p[i] = x;
        g[x].push_back(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    set<pair<int, int>> st;
    st.insert({-s[0], 0});
    emulate(st);
    int pos = 0;
    for (auto el : order) {
        int idx = el;
        while (p[el] != el) {
            int par = p[el];
            sz[el]++;
            update(p[el], sz[el], el);
            //cout << ans1[p[el]].first.first << ' ' << ans1[p[el]].first.second << ' ' << ans1[p[el]].second.first << ' ' << ans1[p[el]].second.second << '\n';
            //cout << idx << ' ' << pos << ' ' << get(p[el], el) << '\n';
            ans[idx] = min(ans[idx], pos - get(p[el], el));
            el = par;
        }
        pos++;
    }
    while (q--) {
        int v;
        cin >> v; v--;
        cout << ans[v] << '\n';
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tests = 1;
    //cin >> tests;
    while (tests--) solve();
}

