//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#pragma GCC optimize("O3,Ofast,fast-math,unroll-loops")
#pragma GCC target("avx,avx2,fma,sse,sse2,sse3,sse4,sse4.1,sse4.2")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long

vector<set<pair<int, int>>>G;
vector<int>c, res;
int mx=0;
vector<int>sz;
int t=0;
set<pair<int, int>>cur;
vector<int>pr;

void dfs(int v) {
    //cout<<v<<" ";
    cur.erase(cur.begin());
    vector<int>path;
    int J=v;
    mx=0;
    while (J!=-1) {
        path.push_back(J);
        J=pr[J];
    }
    sort(path.begin(), path.end());
    int i=0;
    for (int j = 0; j < sz.size(); ++j) {
        if (i < path.size() && path[i]==j) {
            i++;
        } else {
            mx=max(mx, sz[j]);
        }
    }
    res[v]=t-mx;
    t++;
    for (auto i : path) {
        sz[i]++;
    }
    for (auto j : G[v]) {
        cur.insert(j);
    }
    if (cur.size() == 0) {
        return;
    }

    pair<int, int> ne = *cur.begin();
    dfs(ne.second);
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    G.resize(n);
    pr.resize(n, 0);
    c.resize(n, 0);
    res.resize(n, 0);
    sz.resize(n, 0);
    pr[0]=-1;
    for (int i = 1; i < n; ++i) {
        cin>>pr[i];
        pr[i]--;
    }
    for(int i=0;i<n;++i) {
        cin>>c[i];
    }
    for (int i = 1; i < n; ++i) {
        G[pr[i]].insert({-c[i], i});
    }
    cur.insert({0,0});
    dfs(0);
    for (int i = 0; i < q; ++i) {
        int x;cin>>x;x--;
        cout<<res[x]<<" ";
    }
}
