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

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> order, p;
vector<vector<int>> num;
vector<bool> us;

void process() {
    us[0] = true;
    set<pair<int, int>> s;
    for (int u: g[0]) {
        s.insert({p[u], u});
    }
    while (!s.empty()) {
        auto [level, v] = *s.rbegin();
        s.erase({level, v});
        us[v] = true;
        order.pb(v);
        for (int u: g[v]) {
            if (!us[u]) {
                s.insert({p[u], u});
            }
        }
    }
}

vector<int> tin, tout;
int timer = 0;

void dfs(int v, int pr) {
    num[v].pb(v);
    tin[v] = timer++;
    for (int u: g[v]) {
        if (u != pr) {
            dfs(u, v);
            for (int val: num[u]) num[v].pb(val);
        }
    }
    tout[v] = timer++;
}

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), num.resize(n);
    tin.resize(n), tout.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(order); i++) {
        timing[order[i]] = i + 1;
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        int ans = timing[v];
        for (int del = 0; del < n; del++) {
            if (del != v) {
                int cnt = timing[v];
                for (int ma: num[del]) {
                    if (timing[ma] <= timing[v]) cnt--;
                }
                ans = min(ans, cnt);
            }
        }
        cout << ans << " ";
    }
    return 0;
}
