#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define size(t) (int)t.size()
#define pb push_back
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()

using namespace std;

const int N = 3e5 + 5;

vector <int> g[N];
int p[N], s[N], h[N], re[N], ans[N];

void dfs(int i) {
    for (auto j:g[i]) {
        h[j] = h[i] + 1;
        dfs(j);
    }
}

void solve() {
    int n, q, i, j, k;
    cin >> n >> q;
    p[0] = -1;
    for (i = 1; i < n; i++) {
        cin >> p[i];
        p[i] --;
        g[p[i]].pb(i);
    }
    for (i = 0; i < n; i++) {
        cin >> s[i];
        re[s[i]] = i;
    }
    dfs(0);
    int t = 1;
    set <int> cur = {all(g[0])};
    multiset <pair<int, int>> mx;
    for (auto j:g[0]) {
        mx.insert({0, j});
    }
    for (j = n; j >= 1; j--) {
        i = re[j];
        if (cur.count(i)) {
            cur.erase(i);
            mx.erase(mx.find({h[i] - 1, i}));
            while (s[i] >= j) {
                ans[i] = t - (*mx.rbegin()).first;
                t ++;
                if (g[i].empty()) {
                    break;
                }
                i = g[i][0];
            }
            if (g[i].empty() && s[i] >= j) {
                mx.insert({h[i], -1});
            }
            else {
                mx.insert({h[i] - 1, i});
                cur.insert(i);
            }
        }
    }
    while (q--) {
        cin >> i;
        i --;
        cout << ans[i] << ' ';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}



