#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 std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using str = string;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const ll INF = 1e18, MOD = 1e9 + 7;
#define int long long

void solve();

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--) {
        solve();
        cout << "\n";
    }
}

vector<vector<int>> g;
vector<int> col;
vector<int> s;

void dfs(int v) {
    col[v] = 0;
    set<pair<int, int>> u;
    for (auto to: g[v]) {
        u.insert({s[to], to});
    }
    int o = 0;
    while ((int) u.size() > 0) {
        auto k = *u.rbegin();
        u.erase(u.find(k));
        col[k.second] = o + 1;
        for (auto to: g[k.second]) {
            u.insert({s[to], to});
        }
        o++;
    }
}

struct f {
    int l, id, x;
};

bool cmp(f &e1, f &e2) {
    if (e1.l != e2.l) {
        return e1.l < e2.l;
    } else {
        return e1.id < e2.id;
    }
}

vector<ordered_set> d;
vector<f> h;

void dfs1(int v, int pr) {
    for (auto to: g[v]) {
        dfs1(to, v);
        if (d[v].size() < d[to].size()) {
            swap(d[v], d[to]);
        }
        for (auto x: d[to]) {
            auto k = d[v].upper_bound(x);
            int u = (int) g.size();
            if (k != d[v].end()) {
                u = *k;
            }
            if (x + 1 != u) {
                int vb = d[v].order_of_key(x);
                h.push_back({x + 1, 0, vb + 1});
                h.push_back({u - 1, 2, vb + 1});
            }
            d[v].insert(x);
        }
        d[to].clear();
    }
    int x = col[v];
    auto k = d[v].upper_bound(x);
    int u = (int) g.size();
    if (k != d[v].end()) {
        u = *k;
    }
    if (x + 1 != u) {
        int vb = d[v].order_of_key(x);
        h.push_back({x + 1, 0, vb + 1});
        h.push_back({u - 1, 2, vb + 1});
    }
    d[v].insert(x);
}

void solve() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    col.resize(n);
    for (int i = 1; i < n; ++i) {
        int p1;
        cin >> p1;
        p1--;
        g[p1].push_back(i);
    }
    s.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    dfs(0);
    d.resize(n);
    dfs1(0, -1);
    for (int i = 0; i < n; ++i) {
        h.push_back({i, 1, 0});
    }
    sort(h.begin(), h.end(), cmp);
    multiset<int> u;
    vector<int> ans(n);
    for (int i = 0; i < h.size(); ++i) {
        if (h[i].id == 1) {
            if ((int) u.size() != 0) {
                ans[h[i].l] = *u.rbegin();
            }
        } else if (h[i].id == 0) {
            u.insert(h[i].x);
        } else {
            u.erase(u.find(h[i].x));
        }
    }
    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        v--;
        cout << col[v] - ans[col[v]] << " ";
    }
}