#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;
}
pair<pair<int, int>, pair<int, int>> zzz[300'300] = {};
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];
    }
    t = 0;
    tio(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});
        }

        int w = v;
        while (p[w] != w)
        {
            if (zzz[p[w]].st.nd != w)
            { ans[v] = max(ans[v], zzz[p[w]].st.st); }
            if (zzz[p[w]].nd.nd != w)
            { ans[v] = max(ans[v], zzz[p[w]].nd.st); }
            /*
            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];
            if (zzz[p[v]].st.st < bet[v]) {
                zzz[p[v]].nd = zzz[p[v]].st;
                zzz[p[v]].st = (pair<int, int>){bet[v], v};
            } else if (zzz[p[v]].nd.st < bet[v]) {
                zzz[p[v]].nd = (pair<int, int>){bet[v], v};
            }
            v = p[v];
        }

        ++t;
    }

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

    return 0;
}
