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

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;

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

using ordered_set = tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

void solve();

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef _GLIBCXX_DEBUG
    freopen("input", "r", stdin);
#endif
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
}

int tin = 0;
int mx = 0;
const int MAXN = 3e5;
int ans[MAXN];

int dfs(int s, vector<vector<int>> &g) {
    ans[s] = tin++ - mx;
    int sz = 1;
    for (int i: g[s]) {
        sz += dfs(i, g);
    }
    mx = max(mx, sz);
    return sz;
}

void solve() {

    int n, q;
    cin >> n >> q;
    vector<int> p(n, -1);
    vector<vector<int>> g(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    vector<int> s(n);
    for (int &i: s)
        cin >> i;
    for (int i = 0; i < n; i++) {
        sort(all(g[i]), [&](int a, int b) {
            return s[a] > s[b];
        });
    }
    while (q--) {
        int a;
        cin >> a;
        cout << ans[a - 1] << ' ';
    }
}