//author: лелутик :3
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <time.h>
#include <cmath>
#include <cassert>
#include <random>
using namespace std;
#define line cout << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ppb pop_back
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pii pair<int, int>
const int MAXN = 3e5 + 10;
int p[MAXN], s[MAXN];
vector<int> g[MAXN];
int num[MAXN];
int dp[MAXN];
int tin[MAXN], tout[MAXN];
int t = 1;

void dfs2(int v) {
    tin[v] = t++;
    for (auto &u : g[v]) {
        dfs2(u);
    }
    tout[v] = t++;
}


bool check_parent(int a, int b) {
    return tin[a] <= tin[b] && tout[b] <= tout[a];
}


bool cmp(pii a, pii b) {
    return num[a.first] < num[b.first];
}


void solve() {
    int n, q;
    cin >> n >> q;
    p[0] = -1;
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].pb(i);
    }
    dfs2(0);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int cur = 0, cnt = 0;
    set<pii> smezh;
    for (auto &u : g[0]) {
        smezh.insert({s[u], u});
    }
    while (1) {
        num[cur] = cnt;
        cnt++;
        if (sz(smezh) == 0) {
            break;
        }
        auto it = --smezh.end();
        int v = it->second;
        smezh.erase(it);
        for (auto &u : g[v]) {
            smezh.insert({s[u], u});
        }
        cur = v;
    }
    vector<pii> tasks(q);
    for (int i = 0; i < q; i++) {
        cin >> tasks[i].first;
        tasks[i].first--;
        tasks[i].second = i;
    }
    sort(all(tasks), cmp);
    set<pii> st;
    set<pii> qq;
    qq.insert({0, 0});
    vector<int> ans(q);
    for (int i = 0; i < q; i++) {
        while (sz(qq) && qq.begin()->first < num[tasks[i].first]) {
            int v = qq.begin()->second;
            qq.erase(qq.begin());
            for (auto &u : g[v]) {
                qq.insert({num[u], u});
            }
            while (v != -1) {
                st.erase({dp[v], v});
                dp[v]++;
                st.insert({dp[v], v});
                v = p[v];
            }
        }
        int v = tasks[i].first;
        while (v != -1) {
            st.erase({dp[v], v});
            v = p[v];
        }
        int val = 0;
        if (sz(st)) {
            val = (--st.end())->first;
        }
        ans[tasks[i].second] = num[tasks[i].first] - val;
        v = tasks[i].first;
        while (v != -1) {
            st.insert({dp[v], v});
            v = p[v];
        }
    }
    for (int i = 0; i < q; i++) {
        cout << ans[i] << " ";
    }
    line;
}

signed main() {
    fast;


#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}