#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define pii pair<int, int>
#define f first
#define s second
#define ld long double

using namespace std;
using namespace __gnu_pbds;
using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rnd(time(0));

const int MAXN = 1000;
const int INF = 1e9;
vector<int> g[MAXN];
int h[MAXN], s[MAXN], p[MAXN], pos[MAXN], tin[MAXN], tout[MAXN], ans[MAXN];
int cnt[MAXN][MAXN];
int timer;
vector<int> order;

void dfs(int v, int n)
{
    tin[v] = timer++;
    for(int i =0 ; i<n; ++i)
        cnt[v][i] = 0;
    for(auto u:g[v])
    {
        dfs(u, n);
        for(int i = 0; i<n; ++i)
            cnt[v][i] += cnt[u][i];
    }
    for(int i = 0; i<n; ++i)
    {
        if(s[v] >= i) ++cnt[v][i];
        else cnt[v][i] = 0;
    }
    tout[v] = timer++;
    return;
}

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

void solve()
{
    int n, q; cin >> n >> q;
    for(int i = 0; i<n; ++i)
        g[i].clear();
    order.clear();
    h[0] = 0; p[0] = -1;
    for(int i = 1; i<n; ++i)
    {
        int x; cin >> x; --x;
        p[i] = x;
        g[x].push_back(i);
        h[i] = h[x]+1;
    }
    for(int i = 0; i<n; ++i)
    {
        cin >> s[i]; --s[i];
    }
    set<pii> st; st.insert({s[0], 0});
    while(!st.empty())
    {
        pii cur = *(--st.end()); st.erase(--st.end());
        pos[cur.s] = order.size();
        order.push_back(cur.s);
        for(auto u:g[cur.s])
            st.insert({s[u], u});
    }
    dfs(0, n);
    ans[0] = 0;
    for(int j=1; j<n; ++j)
    {
        int v = order[j], cur = j;
        for(int k = j-1; k>=0; --k)
        {
            if(is_par(order[k], v))
                cur = min(cur, ans[order[k]]+j-k);
            else
                cur = min(cur, pos[v] - cnt[order[k]][s[v]]);
        }
        ans[v] = cur;
    }
    for(int j = 0; j<q; ++j)
    {
        int v; cin >> v; --v;
        cout << ans[v] << " ";
    }
    cout << "\n";
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1;
    //freopen("in.txt", "r", stdin); int t; cin >> t;
    //freopen("out.txt", "w", stdout);
    while(t--)
        solve();
    return 0;
}
