#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>

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

vector<int> sz;
void dfs(int v) {
    sz[v] = 1;
    for (auto to : gr[v]) {
        dfs(to);
        sz[v] += sz[to];
    }
}

bool cmp(int v, int u) {
    return s[v] > s[u];
}

vector<int> res;
void dp(int v) {
    sort(gr[v].begin(), gr[v].end(), cmp);
    int sm = 0;
    for (auto to : gr[v]) {
        res[to] = res[v] + sm + 1;
        sm += sz[to];
        dfs(to);
    }
}

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];
    }
    build();
    sz.resize(n);
    res.resize(n);
    dfs(0);
    dp(0);
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        x--;
        cout << res[x] << '\n';
    }
}
