#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long

const int MAXN = 3 * 1e5 + 1;

int tin[MAXN];
int tout[MAXN];
int dp[MAXN];
int sz[MAXN];

int T = 0;

struct SegTree
{
    int n;
    std::vector<int> t;

    SegTree(int n) : n(n)
    {
        t.resize(4 * n);
    }

    void upd(int i, int l, int r, int pos, int x)
    {
        if (l == r - 1)
        {
            t[i] = x;
            return;
        }
        int mid = (l + r) / 2;
        if (pos >= mid)
        {
            upd(2 * i + 2, mid, r, pos, x);
        }
        else
        {
            upd(2 * i + 1, l, mid, pos, x);
        }
        t[i] = std::max(t[2 * i + 1], t[2 * i + 2]);
    }

    int query(int i, int l, int r, int ql, int qr)
    {
        if (l >= ql && r <= qr)
        {
            return t[i];
        }
        if (l >= qr || ql >= r)
        {
            return 0;
        }
        int mid = (l + r) / 2;
        return std::max(query(2 * i + 1, l, mid, ql, qr), query(2 * i + 2, mid, r, ql, qr));
    }
};

void dfs(int v, std::vector<std::vector<int>> &g, SegTree &t, std::vector<int> &p, int pred = -1)
{
    tin[v] = T++;
    sz[v] = 1;

    for (int u : g[v])
    {
        if (u != pred)
        {
            dfs(u, g, t, p, v);
            sz[v] += sz[u];
        }
    }

    t.upd(0, 0, g.size(), p[v], sz[v]);

    tout[v] = T;
}

bool is_pred(int a, int b)
{
    return (tin[a] <= tin[b] && tout[a] >= tout[b]);
}

void dfs1(int v, std::vector<std::vector<int>> &g, SegTree &t, std::vector<int> &help, std::vector<int> &p, int pred = -1)
{
    // std::cout << v << std::endl;
    t.upd(0, 0, g.size(), p[v], 0);

    help[v] = p[v] - t.query(0, 0, g.size(), 0, p[v] + 1);
    // std::cout << v << ' ' << t.query(0, 0, g.size(), 0, p[v] + 1) << std::endl;

    // std::cout << v << std::endl;

    for (int u : g[v])
    {
        if (u != pred)
        {
            dfs1(u, g, t, help, p, v);
        }
    }
    // std::cout << "aaa " << v << ' ' << sz[v] << std::endl;
    t.upd(0, 0, g.size(), p[v], sz[v]);
    // std::cout << v << std::endl;
}

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, q;
    std::cin >> n >> q;

    std::vector<std::vector<int>> g(n);
    std::vector<int> pred(n, -1);
    for (int i = 1; i <= n - 1; i++)
    {
        int p;
        std::cin >> p;
        p--;

        g[p].push_back(i);
        g[i].push_back(p);
        pred[i] = p;
    }

    std::vector<int> s(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> s[i];
        dp[i] = 0;
    }

    // std::cout << "djf" << std::endl;

    std::vector<int> all;
    std::vector<bool> used(n, false);
    std::set<std::pair<int, int>> now;
    int tmp = 0;
    for (int u : g[0])
    {
        now.insert({-s[u], u});
    }
    while (tmp != -1)
    {
        all.push_back(tmp);
        used[tmp] = true;
        if (now.size() == 0)
        {
            break;
        }

        auto th = now.begin()->second;

        now.erase(now.begin());

        for (int u : g[th])
        {
            if (!used[u])
            {
                now.insert({-s[u], u});
            }
        }

        tmp = th;
    }
    std::vector<int> help(n);
    std::vector<int> p(n);
    for (int i = 0; i < all.size(); i++)
    {
        p[all[i]] = i;
    }

    SegTree t(n);

    dfs(0, g, t, p);

    dfs1(0, g, t, help, p);
    // std::cout << ":djf" << std::endl;

    while (q--)
    {
        int x;
        std::cin >> x;
        x--;

        std::cout << help[x] << ' ';
    }
}