#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

typedef long long ll;
//#define int ll
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int N = 3e5 + 10;
const int C = 100;

int n, q, a[N], p[N], tout[N], tmr, ans[N];
vector<int> g[N];
set<pii> child[N];

void dfs(int v) {
    tout[v] = tmr++;
    if((int)child[v].size() == 0) return;
    auto [dx, mx] = *child[v].rbegin();
    child[v].erase({dx, mx});
    if((int)child[v].size() > (int)child[mx].size()) child[mx].swap(child[v]);
    for(auto p : child[v]) {
        if(p.Y != mx) child[mx].insert(p);
    }
    dfs(mx);
}

void solve() {
    cin >> n >> q;
    for(int i = 2; i <= n; ++i) {
        cin >> p[i];
        g[p[i]].pb(i);
    }
    for(int i = 1; i <= n; ++i) cin >> a[i];

    fill(ans, ans + n + 1, INF);

    ordered_set mmxx;
    int sz = 0;
    for(int i = 1; i <= n; ++i) {
        if(p[i] == 1) {
            mmxx.insert(a[i]);
            ++sz;
        }
    }

    for(int i = 1; i <= n; ++i) {
        if(i == 1 || (p[i] == 1 && mmxx.order_of_key(a[i]) + C >= sz)) {
            int x = a[i]; a[i] = 0;
            tmr = 0;
            for(int j = 1; j <= n; ++j) {
                child[j].clear();
                for(int to : g[j]) {
                    child[j].insert({a[to], to});
                }
            }
            dfs(1);
            for(int v = 1; v <= n; ++v) {
                ans[v] = min(ans[v], tout[v]);
            }
            a[i] = x;
        }
    }
    while(q--) {
        int v; cin >> v;
        cout << ans[v] << ' ';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    auto start = clock();
#endif
    int ttt = 1;
    //cin >> ttt;
    while(ttt--) {
        solve();
    }
#ifdef LOCAL
    auto end = clock();
    cerr << "TIME: " << (end - start) << "ms" << '\n';
#endif
}