#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 sup[300'000] = {};

void dfs(int v, int sp)
{
    sup[v] = sp;
    for (int u : G[v])
    {
        dfs(u, sp);
    }
}

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];
    }

    for (int v : G[0])
    {
        dfs(v, v);
    }

    pair<int, int> A, B;

    int 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;
        v = sup[v];

        if (v != 0)
        {
            ans[w] = 0;
            if (A.nd != v) { ans[w] = max(ans[w], A.st); }
            if (B.nd != v) { ans[w] = max(ans[w], B.st); }
            ans[w] = t - ans[w];

            ++bet[v];
            if (A.st < bet[v]) {
                if (A.nd == v) { A.st = bet[v]; }
                else {
                    B = A;
                    A.st = bet[v];
                    A.nd = v;
                }
            } else if (B.st < bet[v]) {
                B.st = bet[v];
                B.nd = v;
            }
        }

        ++t;
    }

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

    return 0;
}
