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

#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pr = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 1;
const ll INFLL = 1e18 + 1;
int reps = 1;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

template<typename T>
inline void print(const vector<T> &a, string sep=" ") {
    for (auto &x : a) cout << x << sep;
    cout << "\n";
}

template<typename T>
inline void print(const set<T> &a, string sep=" ") {
    for (auto &x : a) cout << x << sep;
    cout << "\n";
}


template<typename T>
inline void rr(vector<T> &a, int n) {
    a.clear();
    a.resize(n);
}

//====================================

vector<vector<int>> g;
vector<int> p, s, sz, tin, tout;
int timer = 0;

void dfs(int v) {
    tin[v] = timer++;
    sz[v] = 1;
    for (auto u : g[v]) {
        dfs(u);
        sz[v] += sz[u];
    }
    tout[v] = timer;
}

void dfs2(int v, int &mx, vector<int> &d, vector<int> &ord) {
    d[v] = mx;
    ord.push_back(v);
    sort(all(g[v]), [&](int i, int j) {
        return s[i] > s[j];
    });
    for (auto u : g[v]) {
        dfs2(u, mx, d, ord);
    }

    mx = max(mx, sz[v]);
} 

bool isp(int v, int u) {
    return tin[v] <= tin[u] && tout[v] >= tout[u];
}

void solve() {
    int n, q; cin >> n >> q;
    rr(g, n); rr(p, n); rr(s, n); rr(tin, n); rr(tout, n); rr(sz, n);
    timer = 0;
    for (int i = 1; i < n; i++) {
        cin >> p[i]; p[i]--;
        g[p[i]].push_back(i);
    }
    for (auto &x : s) cin >> x;

    dfs(0);

    // int root = 0;
    // vector<int> ord, d;
    // priority_queue<pii> qq;
    // int mx = 0;
    // while (root != -1) {
    //     ord.push_back(root);
    //     for (auto u : g[root]) qq.push({s[u], u});
    //     if (qq.empty()) root = -1;
    //     else {
    //         auto [cd, nv] = qq.top(); qq.pop();
    //         root = nv;
    //     }
    // }

    vector<int> ord, d(n);
    int mx = 0;
    dfs2(0, mx, d, ord);

    // print(d);
    // print(ord);

    for (int i = 0; i < n; i++) {
        int v = ord[i];
        d[v] = i - d[v];
    }

    while (q--) {
        int v; cin >> v; v--;
        cout << d[v] << " ";     
    }
    cout << "\n";
}
                                                                                                                                                                    
//====================================

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL 
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin >> reps;
#endif
    for (int i = 0; i < reps; i++) {
#ifdef LOCAL 
        cout << "Test case #" << i + 1 << " ==============\n";
#endif
        solve();
#ifdef LOCAL 
        cout << "End test ==============\n";
#endif
    }
    return 0;
}

// g++ -std=c++23 -Wall -Wextra -Wshadow -DLOCAL -D_GLIBCXX_DEBUG -fsanitize=address,undefined -O2 A.cpp -o A
