#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi2")

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <typename T>
using ordered_set = __gnu_pbds::tree <T, __gnu_pbds::null_type, less <T>,
        __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template <typename T>
int sz(const T &x) {
    return static_cast <int> (x.size());
}

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 3e5;
const int INF = 2e9;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-8;

struct Person {
    int number, competitive_cnt, path_number;
    friend bool operator< (Person a, Person b) {
        return a.competitive_cnt < b.competitive_cnt;
    }
};

struct Path {
    int path_number, kicked;
    friend bool operator< (Path a, Path b) {
        return a.kicked < b.kicked;
    }
};

int paths_cnt = 0;
vector <int> g[MAXN];
int p[MAXN], s[MAXN];
int ans[MAXN];
vector <deque <Person>> paths;
vector <int> path_kicked;

void dfs(int v) {
    paths.back().push_back(Person {v, s[v], sz(paths) - 1});
    for (auto to : g[v]) {
        if (to != p[v]) {
            if (v == 1) {
                paths_cnt++;
                paths.push_back({});
                path_kicked.push_back(0);
            }
            dfs(to);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    for (int v = 1; v < n; v++) {
        cin >> p[v]; p[v]--;
        g[p[v]].emplace_back(v);
    }
    for (int v = 1; v < n; v++) {
        cin >> s[v];
    }
    dfs(0);
    ans[0] = 0;
    if (paths_cnt == 1) {
        for (auto [number, competitive_cnt, path_number] : paths[0]) {
            ans[number] = ans[p[number]] + 1;
        }
        while (q--) {
            int v;
            cin >> v; v--;
            cout << ans[v] << ' ';
        }
        return 0;
    }
    multiset <Person> most_competitive;
    multiset <Path> path_kicked_max;
    for (auto& i : paths) {
        most_competitive.insert(i.front());
        path_kicked_max.insert(Path {i.front().path_number, 0});
    }
    int kicked_all = 1;
    while (!most_competitive.empty()) {
        int number = (--most_competitive.end())->number;
        int path_number = (--most_competitive.end())->path_number;
        int tmp = kicked_all - ((--path_kicked_max.end())->kicked);
        if (sz(path_kicked_max) >= 2 && (--path_kicked_max.end())->path_number == path_number) {
            tmp += (--path_kicked_max.end())->kicked;
            tmp -= (----path_kicked_max.end())->kicked;
        }
        ans[number] = tmp;
        path_kicked_max.erase(path_kicked_max.find(Path {path_number, path_kicked[path_number]}));
        path_kicked[path_number]++;
        kicked_all++;
        path_kicked_max.insert(Path {path_number, path_kicked[path_number]});
        most_competitive.erase(--most_competitive.end());
        paths[path_number].pop_front();
        if (!paths[path_number].empty()) {
            most_competitive.insert(paths[path_number].front());
        }
    }
    while (q--) {
        int v;
        cin >> v;
        cout << ans[v] << ' ';
    }
    return 0;
}
