#include <iostream>
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define st first
#define nd second

/**
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
**/

vector<vector<int>> G;
vector<int> p;
vector<int> s;

int tin[300'300];
int tou[300'300];

int t;

void tio(int v)
{
    tin[v] = t; ++t;
    for (int u : G[v])
    {
        tio(u);
        ++t;
    }
    tou[v] = t - 1;
}

int bet[300'300] = {};
int ans[300'300] = {};

signed main()
{
    int n, q;
    cin >> n >> q;
    p.resize(n);
    s.resize(n);
    G.resize(n);
    p[0] = 0;
    for (int i = 1; i < n; ++i)
    {
        cin >> p[i];
        --p[i];
        G[p[i]].push_back(i);
    }
    for (int i = 0; i < n; ++i)
    {
        cin >> s[i];
    }
    int t = 0;

    t = 0;
    set<pair<int, int>, std::greater<pair<int, int>>> S;
    S.insert({s[0], 0});
    while (S.size())
    {
        int v = S.begin()->nd;
        S.erase(S.begin());
        for (int u : G[v])
        {
            S.insert({s[u], u});
        }

        for (int u : G[0])
        {
            if (w != u)
            {
                ans[v] = max(ans[v], bet[u]);
            }
        }
/*
        int w = v;
        while (p[w] != w)
        {
            for (int u : G[p[w]])
            {
                if (w != u)
                {
                    ans[v] = max(ans[v], bet[u]);
                }
            }
            w = p[w];
        }
*/
        ans[v] = t - ans[v];

        while (p[v] != v)
        {
            ++bet[v];
            v = p[v];
        }

        ++t;
    }

    for (int _ = 0; _ < q; ++_)
    {
        int v;
        cin >> v; --v;
        cout << ans[v] << ' ';
    } cout << '\n';

    return 0;
}
