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

using namespace std;
using namespace __gnu_pbds;
int n;
vector<int> p, s;
vector<vector<int>> gr;
vector<vector<int>> gr_hld;
bool comp(int i, int j) {
    return s[i] > s[j];
}

vector<int> sz;
bool comp2(int i, int j) {
    return sz[i] > sz[j];
}
vector<int> ans;
vector<int> tin, tout;
int tme = 0;
void calc_sz(int v) {
    sz[v] = 1;

    for (auto x : gr[v]) {
        calc_sz(x);
        sz[v] += sz[x];
    }

}
bool a(int u, int v) {
    if (u == v) return true;
    return tin[u] <= tin[v] && tin[v] < tout[u];
}
vector<int> hd;
void build(int v, int det) {
    tin[v] = tme++;
    hd[v] = det;
    if (!gr[v].empty()) {
        build(gr[v][0], v);
    }
    for (int i = 1; i < gr[v].size(); i++) {
        build(gr[v][i], gr[v][i]);
    }
    tout[v] = tme;
}
vector<pair<int, int>> ot(int v) {
    vector<pair<int, int>> z;
    while (true) {
        int le = hd[v];
        int re = v;
        z.push_back({tin[le], tin[re]});
        if (le == 0) break;
        v = p[le];
    }
    return z;
}
const int N = 300001;
int t[4 * N];
int ph[4 * N];
void apply(int v, int l, int r, int val) {
    t[v] += val;
    ph[v] += val;
}
void push(int v, int l, int r) {
    if (ph[v] != 0 && r - l > 1) {
        int m = (l + r) / 2;
        apply(2 * v + 1, l, m, ph[v]);
        apply(2 * v + 2, m, r, ph[v]);
        ph[v] = 0;
    }
}
void update(int v, int l, int r, int ql, int qr, int val) {
    if (ql <= l && r <= qr) {
        apply(v, l, r, val);
        return;
    }
    if (r <= ql || qr <= l) return;
    push(v, l, r);
    int m = (l + r) / 2;
    update(2 * v + 1, l, m, ql, qr, val);
    update(2 * v + 2, m, r, ql, qr, val);
    t[v] = max(t[2 * v + 1], t[2 * v + 2]);
}
int get(int v, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) {
        return t[v];
    }
    if (r <= ql || qr <= l) return 0;
    push(v, l, r);
    int m = (l + r) / 2;
    return max(get(2 * v + 1, l, m, ql, qr), get(2 * v + 2, m, r, ql, qr));
}
signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int q; cin >> n >> q;
    p.resize(n);
    gr.resize(n);
    sz.resize(n);
    tin.resize(n);
    hd.resize(n);
    tout.resize(n);
    gr_hld.resize(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        gr[p[i]].push_back(i);
        gr_hld[p[i]].push_back(i);
    }
    ans.resize(n);
    s.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    calc_sz(0);
    for (int i = 0; i < n; i++) {
        sort(gr[i].begin(), gr[i].end(), comp);
        sort(gr_hld[i].begin(), gr_hld[i].end(), comp2);
    }

    build(0, 0);
    //sz.assign(n, 0);
    vector<int> vst;
    set<pair<int, int>> qr;
    qr.insert({s[0], 0});
    vector<int> ans(n);

    while (!qr.empty()) {
        auto [st,v] = *qr.rbegin();
        qr.erase({st, v});
        vst.push_back(v);
        vector<pair<int, int>> qe = ot(v);
        for (auto [le, re]: qe) {
            update(0, 0, n, le, re + 1, 1);
        }
        for (auto x : gr[v]) {
            qr.insert({s[x], x});
        }
        ans[v] = vst.size() - 1;
        for (auto x : vst) {
            if (!a(x, v)) {
                ans[v] = min(ans[v], (int)vst.size() - 1 - get(0, 0, n, tin[x], tin[x] + 1));
            }
        }
    }
    while (q--) {
        int u; cin >> u;
        u--;
        cout << ans[u] << ' ';
    }
    return 0;
}
