#include <bits/stdc++.h>
using namespace std;
#define ll long long

struct node {
    int mx;
    int id;
};

struct tree {
    int n;
    vector<node> t;

    tree(int N) : n(N) {
        t.resize(4 * n, {-10000000, 0});
    }
    node merge(node a, node b) {
        if (a.mx > b.mx) return a;
        return b;
    }
    void upd(int v, int l, int r, int pos, ll x) {
        if (r - l == 1) {
            t[v] = {x, l};
            return;
        }
        int m = ((r + l)>>1);
        if (pos < m) upd(2 * v + 1, l, m, pos, x);
        else upd(2 * v + 2, m, r, pos, x);
        t[v] = merge(t[2 * v + 1], t[2 * v + 2]);
    }
    node get_ans(int v, int l, int r, int ql, int qr) {
        if (ql <= l && r <= qr) {
            return t[v];
        }
        if (r <= ql || qr <= l) {
            return {-10000000, 0};
        }
        int m = ((r + l)>>1);
        return merge(get_ans(2 * v + 1, l, m, ql, qr), get_ans(2 * v + 2, m, r, ql, qr));
    }
};


vector<vector<int>> g;

void solve() {
    int n, q; cin >> n >> q;
    g.resize(n);
    for (int i = 1; i < n; ++i) {
        int x; cin >> x;
        g[x-1].push_back(i);
    }
    vector<int> c(n);
    for (int i = 0; i < n; ++i) cin >> c[i];
    vector<int> ans(n, 1000000000);

    for (int i = 0; i < n; ++i) {
            //cout << '\n';
        priority_queue<pair<int, int>> pq;
        int cur = 0;
        pq.push({c[0], 0});
        while (!pq.empty()) {
            auto [C, v] = pq.top();
            pq.pop();
            if (v != i && i != 0) {
                    //cout << v << ' ' << cur << '\n';
                ans[v] = min(ans[v], cur);
                for (int to : g[v]) {
                    pq.push({c[to], to});
                }
                cur++;
            }
        }
    }

    while (q--) {
        int x; cin >> x;
        cout << ans[x-1] << '\n';
    }
}

int main()
{
/*
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
*/
    int ttt = 1;
    //cin >> ttt;
    while (ttt--) {
        solve();
    }
}
