#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#define int long long

using namespace std;

vector<int> t, a;

void build(int v, int l, int r) {
    if (l == r - 1) {
        t[v] = a[l];
        return;
    }
    int m = (r + l) / 2;
    build(2 * v + 1, l, m);
    build(2 * v + 2, m, r);
}

int ask(int v, int l, int r, int askl, int askr) {
    if (l >= askr || r <= askl) {
        return 0;
    }
    if (l >= askl && r <= askr) {
        return t[v];
    }
    int m = (r + l) / 2;
    return ask(2 * v + 1, l, m, askl, askr) + ask(2 * v + 2, m, r, askl, askr);
}

void change(int v, int l, int r, int pos, int val) {
    if (l == r - 1) {
        t[v] = val;
        return;
    }
    int m = (r + l) / 2;
    if (pos < m) {
        change(2 * v + 1, l, m, pos, val);
    } else {
        change(2 * v + 2, m, r, pos, val);
    }
}

vector<vector<int>> gr;
vector<int> p, s, qs, pr;
multiset<pair<int, int>> vs;

void build() {
    int n = p.size();
    vs.insert({s[0], 0});
    while (qs.size() < n) {
        auto elem = *(--vs.end());
        qs.push_back(elem.second);
        vs.erase(elem);
        for (auto to: gr[elem.second]) {
            vs.insert({s[to], to});
        }
    }
}

int fl = false;
void dfs(int v, int pp) {
    if (fl) {
        pr[v] = pp;
    }
    for (auto to : gr[v]) {
        if (!fl && gr[v].size() > 1) {
            fl = true;
            pr[to] = to;
            dfs(to, to);
            fl = false;
        } else if (gr[v].size() > 1) {
            dfs(to, pp);
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    p.resize(n);
    s.resize(n);
    gr.resize(n);
    pr.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        cin >> p[i + 1];
        p[i + 1]--;
        gr[p[i + 1]].push_back(i + 1);
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    vector<vector<int>> qr(n);
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        x--;
        qr[x].push_back(i);
    }
    build();
    dfs(0, 0);
    set<pair<int, int>> c;
    vector<int> cnt(n);
    vector<int> ans(q);
    for (int i = 0; i < n; ++i) {
        int res = 0;
        int v = qs[i];
        while (v) {
            cnt[v]++;
            int u = p[v];
            if (gr[u].size() > 1) {
                for (auto to : gr[u]) {
                    if (to != v) {
                        res = max(res, cnt[to]);
                    }
                }
            }
            v = u;
        }
        for (auto to : qr[qs[i]]) {
            ans[to] = i - res;
        }

    }
    for (auto elem : ans) {
        cout << elem << ' ';
    }
}
