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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3, unroll-loops")
using namespace __gnu_pbds;
using namespace std;
using ordered_set = tree<long long, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using ld = long double;
using str = string;
#define all(a) a.begin(), a.end()
#define len(a) int(a.size())
#define pb push_back
#define pbb pop_back
#define vc vector
#define rev reverse
#define F first
#define S second
vector<vector<int>> g;
vector<int> p, ans, id, order;
vector<vector<int>> pr;
vector<bool> us;

void process() {
    us[0] = true;
    map<int, int> mp, cnt;
    cnt[0] = 1;
    order[0] = 1;
    for (int u: g[0]) {
        mp[p[u]] = u;
    }
    while (!mp.empty()) {
        auto [level, v] = *mp.rbegin();
        mp.erase(level);
        us[v] = true;
        id.pb(v);
        for (int u: g[v]) {
            if (!us[u]) {
                mp[p[u]] = u;
            }
        }
    }
}

void dfs(int v, int parent) {
    if (parent != -1) {
        for (int var: pr[parent]) pr[v].pb(var);
    }
    pr[v].pb(v);
    for (int u: g[v]) {
        if (u != parent) {
            dfs(u, v);
        }
    }
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    g.resize(n), p.resize(n), us.assign(n, false), pr.resize(n);
    ans.resize(n), order.resize(n);
    for (int i = 1; i < n; i++) {
        int par;
        cin >> par;
        g[par - 1].pb(i);
        g[i].pb(par - 1);
    }
    for (int i = 0; i < n; i++) cin >> p[i];
    dfs(0, -1);
    process();
    vector<int> timing(n);
    for (int i = 0; i < len(id); i++) {
        timing[id[i]] = i + 1;
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        cout << timing[v] << "\n";
    }
    return 0;
}
