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

#define int long long
#define db long double
#define MX LLONG_MAX
#define MN LLONG_MIN
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a / gcd(a, b) * b)

using namespace std;
using namespace __gnu_pbds;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int N = 3e5 + 52;

vector<int> g[N];

void dfs(int v, int d, vector<int>& dep) {
    dep[v] = d;

    for (auto to: g[v]) {
        dfs(to, d + 1, dep);
    }
}

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

    int n, q;
    cin >> n >> q;

    vector<int> p(n);
    p[0] = -1;

    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> dep(n);
    dfs(0, 0, dep);

    vector<int> conv(n);
    int sz = g[0].size();
    vector<vector<int>> b(sz);
    for (int i = 0; i < sz; i++) {
        int cur = g[0][i];
        conv[cur] = i;
        b[i].push_back(cur);
        while (g[cur].size() != 0) {
            cur = g[cur][0];
            conv[cur] = i;
            b[i].push_back(cur);
        }
    }

    vector<vector<int>> pref(sz);
    for (int i = 0; i < sz; i++) {
        pref[i].resize(b[i].size() + 1);
        pref[i][0] = MX;

        for (int j = 1; j <= b[i].size(); j++) {
            pref[i][j] = min(pref[i][j - 1], a[b[i][j - 1]]);
        }
     }

    while (q--) {
        int v;
        cin >> v;
        v--;

        if (v == 0) {
            cout << 0 << " ";
            continue;
        }

        int ans = 0;
        int cur = p[v];
        while (cur != -1) {
            ans++;
            cur = p[cur];
        }

        if (b.size() == 1) {
            cout << ans << " ";
            continue;
        }

        int ind = !conv[v];
        //cout << dep[v] << " " << "\n";
        //cout << "!!!" << pref[!ind][dep[v]] << "\n";
        int l = 0, r = b[ind].size();
        while (r - l > 1) {
            int m = (l + r) / 2;
            //cout << "l = " << l << " r = " << r << "\n";

            if (pref[ind][m] > pref[!ind][dep[v]]) {
                l = m;
            } else {
                r = m - 1;
            }
        }

        //cout << "!l = " << l << " r = " << r << "\n";
        if (pref[ind][r] > pref[!ind][dep[v]]) {
            ans += r;
            //cout << "r = " << r << "\n";
        } else {
            ans += l;
            //cout << "l = " << l << "\n";
        }

        cout << ans << " ";
    }
}

/*
6 1
1 2 1 4 5
6 9 2 4 6 10
5
*/

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

#define int long long
#define db long double
#define MX LLONG_MAX
#define MN LLONG_MIN
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a / gcd(a, b) * b)

using namespace std;
using namespace __gnu_pbds;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int N = 3e5 + 52;

vector<int> g[N];
ordered_set st[N];

void dfs(int v, const vector<int>& conv) {
    st[v].insert(conv[v]);

    for (auto to: g[v]) {
        dfs(to, conv);

        for (auto x: st[to]) {
            st[v].insert(x);
        }
    }
}

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

    int n, q;
    cin >> n >> q;

    vector<int> p(n);
    p[0] = -1;

    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    priority_queue<pair<int, int>> pq;
    pq.push({a[0], 0});

    int ind = 0;
    vector<int> conv(n);
    while (!pq.empty()) {
        auto [w, v] = pq.top();
        pq.pop();

        conv[v] = ind++;

        for (auto to: g[v]) {
            pq.push({a[to], to});
        }
    }

    dfs(0, conv);

    while (q--) {
        int v;
        cin >> v;
        v--;

        if (v == 0) {
            cout << 0 << " ";
            continue;
        }

        int ans = 0, mx = 0;
        int cur = p[v], last = v;
        while (cur != -1) {
            for (auto to: g[cur]) {
                //if (to == last) cout << "skip " << to + 1 << "\n";
                if (to == last) continue;
                auto it = st[to].lower_bound(conv[v]);
                int sum;
                if (it == st[to].end()) sum = st[to].size();
                else sum = st[to].order_of_key(*it);
                mx = max(mx, sum);
                ans += sum;
                //cout << "from " << to + 1 << " - ";
                //cout << sum << "\n";
            }

            last = cur;
            cur = p[cur];
            ans++;
        }

        //cout << "!ans = ";
        cout << ans - mx << " ";
    }
}
*/
