//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
template<class T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
//using ld = long double;

#define all(x) begin(x), end(x)
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
vector<ll> h;

void dfs(ll v, ll p, vector<vector<ll>> &g){
    h[v] = p;
    ll cnt = 0;
    for (auto &x: g[v]) dfs(x, (v ? p : cnt++), g);
}

vector<pair<ll,ll>> fill_qq(vector<vector<ll>> &g, vector<ll> &s){
    vector<pair<ll,ll>> ans;
    ans.reserve(g.size());
    set<pair<ll,ll>> ss;
    ll now = 0;
    for (int i=0; i<g.size()-1; ++i){
        for (auto &x: g[now]) ss.insert({-s[x], x});
        now = (*ss.begin()).second;
        ans.push_back({h[now], now});
        ss.erase(ss.begin());
    }
    return ans;
}

void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> p(n);
    p[0] = -1;
    vector<vector<ll>> g(n);
    for (ll i = 0; i < n - 1; ++i) {
        ll x;
        cin >> x;
        --x;
        g[x].push_back(i + 1);
        p[i + 1] = x;
    }
    vector<ll> s(n);
    for (auto &x: s) cin >> x;
    h.resize(n);
    dfs(0, -1, g);
    vector<ll> ans(n);
    auto qq = fill_qq(g, s);
    for (auto &x: qq) cout << x.first << ' ' << x.second << '\n';
    pair<ll,ll> ma={0, 0}, sma={0, 1};
    vector<ll> cnt(n);
    for (int i=0; i<qq.size(); ++i){
        if (ma.second == qq[i].first) ans[qq[i].second] = i - sma.first + 1;
        else ans[qq[i].second] = i - ma.first + 1;
        cnt[qq[i].first]++;
        if (qq[i].first == sma.second){
            sma.first++;
            continue;
        } if (qq[i].first == ma.second){
            ma.first++;
            continue;
        }
        if (cnt[qq[i].first] > sma.first) sma.first = cnt[qq[i].first], sma.second = qq[i].first;
        if (sma > ma) swap(sma, ma);
    }
    while (q--){
        int x;
        cin >> x;
        --x;
        cout << ans[x] << ' ';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll t = 1;
//    cin >> t;
    while (t--) solve(), cout << '\n';
    return 0;
}
