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

const int maxn = 1e6;
int s[maxn], p[maxn], ans[maxn], sz[maxn];
vector<int> g[maxn], order;

void emulate(set<pair<int, int>> st) {
    while (!st.empty()) {
        auto [x, v] = *st.begin();
        for (auto u : g[v]) {
            st.insert({-s[u], u});
        }
        order.push_back(v);
        st.erase({x, v});
    }
}

pair<int, int> ans1[maxn][2];

void update(int v, int x, int y) {
    if (ans1[v][0].second == x) {
        ans1[v][0].first = y;
        if (ans1[v][0].first < ans1[v][1].first) {
            swap(ans1[v][0], ans1[v][1]);
        }
        return;
    }
    if (ans1[v][1].second == x) {
        ans1[v][1].first = y;
        if (ans1[v][0].first < ans1[v][1].first) {
            swap(ans1[v][0], ans1[v][1]);
        }
        return;
    }
    if (ans1[v][0].first <= y) {
        swap(ans1[v][0], ans1[v][1]);
        ans1[v][0] = {y, x};
        return;
    }
    if (ans1[v][1].first <= y) {
        ans1[v][1] = {y, x};
    }
}

int get(int v, int ban) {
    if (ans1[v][0].second == ban) {
        return ans1[v][1].first;
    }
    return ans1[v][0].first;
}

void dfs(int v) {
    for (auto u : g[v]) {
        dfs(u);
        sz[v] += sz[u];
        update(v, u, sz[u]);
    }
}

void solve() {
    int n, q;
    cin >> n >> q;
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x; x--;
        p[i] = x;
        g[x].push_back(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    fill(ans, ans + n, 1e7);
    set<pair<int, int>> st;
    st.insert({-s[0], 0});
    emulate(st);
    int pos = 0;
    /*for (auto el : order) {
        int idx = el;
        ans[idx] = pos;
        while (p[el] != el) {
            int par = p[el];
            sz[el]++;
            update(p[el], el, sz[el]);
            ans[idx] = min(ans[idx], pos - get(p[el], el));
            el = p[el];
        }
        /*cout << "DEBUG\n";
        for (int i = 0; i < n; i++) {
            cout << i << ' ' << ans1[i][0].first << ' ' << ans1[i][0].second << '\n';
        }
        cout << "ENDDEBUG\n";
        pos++;
    }*/
    while (q--) {
        int v;
        cin >> v; v--;
        int pos = 0;
        fill(sz, sz + n, 0);
        pair<int, int> empt = {0, 0};
        fill(ans1[0], ans1[0] + n, empt);
        fill(ans1[1], ans1[1] + n, empt);
        for (auto el : order) {
            if (el == v) break;
            sz[el]++;
            pos++;
        }
        dfs(0);
        int idx = v, el = v;
        ans[idx] = pos;
        while (p[el] != el) {
            int par = p[el];
            ans[idx] = min(ans[idx], pos - get(p[el], el));
            el = p[el];
        }
        cout << ans[idx] << '\n';
        /*cout << "DEBUG\n";
        for (int i = 0; i < n; i++) {
            cout << i << ' ' << ans1[i][0].first << ' ' << ans1[i][0].second << '\n';
        }
        cout << "ENDDEBUG\n";
        pos++;
        cout << ans[v] << ' ';*/
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tests = 1;
    while (tests--) solve();
}

