#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2", "avx")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vc vector<char>
#define vvc vector<vc>
#define pii pair<int, int>
#define ll long long

#define f(i, n) for(int i=0;i<n;i++)
#define f1(i, n) for(int i=1;i<n;i++)
#define fr(i, n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(), v.end()

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<>, rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ti;

int n, q;
vi p;
vvi ch;
vi s;
vi vs;
vi rres;

void tr()
{
    priority_queue<pii> now;
    now.push({-s[0], 0});
    int res = 0;
    while (now.size() > 0)
    {
        pii cur = now.top();
        int v = cur.second;
        now.pop();
        rres[v] = min(rres[v], res);
        for (int u : ch[v])
            now.push({-s[u], u});
        res++;
    }
}

void get()
{
    f(i, n)
    {
        int was = s[i];
        s[i] = 0;
        tr();
        s[i] = was;
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> q;
    p = vi(n);
    rres = vi(n, 1e9);
    rres[0] = 0;
    f1(i, n)
    {
        cin >> p[i];
        p[i]--;
    }

    ch = vvi(n);
    f1(i, n)
    {
        ch[p[i]].push_back(i);
    }

    s = vi(n);
    f(i, n)
        cin >> s[i];
    vs = vi(q);
    f(i, q)
    {
        cin >> vs[i];
        vs[i]--;
    }

    get();

    f(i, q)
    {
        cout << rres[vs[i]] << '\n';
    }

    return 0;
}