#ifdef LOCAL
// #define _GLIBCXX_DEBUG
#else
#pragma GCC optimize("O3")
#endif

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class T> using oset = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())
using ld = long double;
using ll = int64_t;
using ull = uint64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;

void solve();

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

int n, q;
vector<vector<int>> g;
vector<int> s;
vector<int> p;
vector<int> queries;
vector<int> ans;
vector<int> initial_order;
vector<vector<int>> all_sub_s;
vector<vector<pii>> questions;

struct cmp {
    bool operator()(const int a, const int b) const {
        return s[a] > s[b];
    }
};

vector<int> simulate() {
    vector<int> order(n);
    int root = 0;
    vector<set<int, cmp>> leika(n);
    for (int i = 0; i < n; i++) {
        for (int j : g[i]) {
            leika[i].insert(j);
        }
    }
    int t = 0;
    while (!leika[0].empty()) {
        int v = *leika[0].begin();
        leika[0].erase(leika[0].begin());
        order[root] = t;
        ++t;
        root = v;
        if (leika[0].size() < leika[v].size()) {
            swap(leika[0], leika[v]);
        }
        leika[0].insert(all(leika[v]));
        leika[v].clear();
    }
    order[root] = t;
    return order;
}

void dfs(int v) {
    int my_order = initial_order[v];
    int z = v;
    if (queries[v] != -1) {
    while (z != 0) {
        for (int u : g[p[z]]) {
            if (u != z) {
                questions[u].push_back({initial_order[v], queries[v]});
                // for (int i : all_sub_s[u]) {
                //     if (initial_order[i] < my_order) {
                //         now_before++;
                //     }
                // }
            }
        }
        z = p[z];
    }
        // ans[queries[v]] = initial_order[v] - before;
    }
    for (int u : g[v]) {
        dfs(u);
    }
}

void dfs2(int v, oset<int>& s) {
    for (int u : g[v]) {
        oset<int> b;
        dfs2(u, b);
        if (b.size() > s.size()) {
            swap(b, s);
        }
        for (int x : b) {
            s.insert(x);
        }
    }
    s.insert(initial_order[v]);
    for (auto [their_order, their_i] : questions[v]) {
        ans[their_i] = min(ans[their_i], their_order - int(s.order_of_key(their_order)));
    }
}

void solve() {
    cin >> n >> q;
    p.resize(n, -1);
    g.resize(n);
    s.resize(n);
    ans.resize(q, n);
    questions.resize(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    for (int i = 0; i < n; i++) cin >> s[i];
    queries.resize(n, -1);
    for (int i = 0; i < q; i++) {
        int v;
        cin >> v;
        v--;
        queries[v] = i;
    }
    initial_order = simulate();
    for (int u : g[0]) {
        dfs(u);
    }
    oset<int> s;
    dfs2(0, s);
    for (int i = 0; i < q; i++) {
        ans[i] = min(ans[i], initial_order[i]);
        cout << ans[i] << ' ';
    }
    // for (int i = 0; i < q; i++) {
    //     int v = queries[i];
    //     int mn = n;
    //     for (int u = 0; u < n; u++) {
    //         int su = s[u];
    //         s[u] = 0;
    //         vector<int> order = simulate();
    //         mn = min(mn, int(find(all(order), v) - order.begin()));
    //         s[u] = su;
    //     }
    //     cout << mn << '\n';
    // }
}