#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <bitset>

typedef long long ll;
typedef double db;
typedef long double ld;

#define pb push_back
#define sz(s) int(s.size())
#define mp make_pair
#define all(s) s.begin(), s.end()

const int MAX_N = 3e5 + 10;
const int LOG = 20;
const ld EPS = 1e-7;
const ll INF = 1e18;

using namespace std;

vector <int> g[MAX_N];
bool used[MAX_N];
int s[MAX_N];
set <pair <int, int>> po; // char, index
int ind_in_order[MAX_N];
vector <int> order;
vector <pair <int,int>> pod_derevo[MAX_N];
ll ans[MAX_N];
int ind_of_quest_by_vert[MAX_N];
set <int> now;
void dfs(int v) {
    used[v] = true;
    pod_derevo[v] = {mp(ind_in_order[v], v)};
    for (int u : g[v]) {
        if (!used[u]) {
            dfs(u);
            for (auto p : pod_derevo[u]) {
                pod_derevo[v].pb(p);
            }
        }
    }
    sort(all(pod_derevo[v]));
}
void dfs2(int v) {
    used[v] = true;
    if (ind_of_quest_by_vert[v] != 0) {
        if (sz(now) == 0) {
            ans[ind_of_quest_by_vert[v]] = ind_in_order[v];
        } else {
            ans[ind_of_quest_by_vert[v]] = ind_in_order[v];
            for (int i : now) {
                auto x = ind_in_order[v] -
                (lower_bound(pod_derevo[i].begin(), pod_derevo[i].end(), mp(ind_in_order[v], -1)) - pod_derevo[i].begin());
                if (ans[ind_of_quest_by_vert[v]] > x) {
                    ans[ind_of_quest_by_vert[v]] = x;
                }

            }
        }
    }
    for (int u : g[v]) {
        if (!used[u]) {
            now.insert(u);
        }
    }
    for (int u : g[v]) {
        if (!used[u]) {
            now.erase(u);
            dfs2(u);
            now.insert(u);
        }
    }
    for (int u : g[v]) {
        if (!used[u]) {
            now.erase(u);
        }
    }
}

int main () {
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    for (int i = 2; i <= n; i++) {
        int p;
        cin >> p;
        g[i].pb(p);
        g[p].pb(i);
    }
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    po.insert(mp(s[1], 1));
    while (sz(order) != n) {
        auto p = *(--po.end());
        po.erase(p);
        ind_in_order[p.second] = sz(order);
        order.pb(p.second);
        used[p.second] = true;
        for (int u : g[p.second]) {
            if (!used[u]) {
                po.insert(mp(s[u], u));
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        used[i] = false;
    }
    for (int i = 1; i <= q; i++) {
        int x; cin >> x;
        ind_of_quest_by_vert[x] = i;
    }
    dfs(1);
    for (int i = 1; i <= n; i++) {
        used[i] = false;
    }
    dfs2(1);
    for (int i = 1; i <= q; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;






}
