#include <bits/stdc++.h>
using namespace std;
#define int long long
//#pragma GCC optimize("O3,unroll-loops")

template<typename T>
istream& operator>>(istream& in, vector<T>& v) {
    for (T& i : v) in >> i;
    return in;
}

const int maxn = 300005;
vector<int> g[maxn];
int s[maxn];
int tin[maxn], tout[maxn];

int timer = 0;
vector<int> tinv;
void dfs(int v) {
    tinv.push_back(v);
    tin[v] = timer++;
    for (int u : g[v])
        dfs(u);
    tout[v] = timer;
}



void solve() {
    int n, q;
    cin >> n >> q;
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }

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

    set<pair<int, int>> child;
    child.insert({-s[0], 0});
    vector<int> vec;

    while (!child.empty()) {
        auto [u, v] = *child.begin();
        child.erase(child.begin());
        for (int t : g[v]) {
            child.insert({-s[t], t});
        }
        vec.push_back(v);
    }

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

    vector<vector<int>> e(n);

//    for (int i = 1; i < n; i++) {
//        queue<int> q;
//        q.push(i);
//        while (!q.empty()) {
//            int v = q.front();
//            q.pop();
//            for (int u : g[v]) {
//                q.push(u);
//            }
//            e[i].push_back(pos[v]);
//        }
//        sort(e[i].begin(), e[i].end());
//    }

    for (int i : g[0]) {
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int u : g[v]) {
                q.push(u);
            }
            e[i].push_back(pos[v]);
        }
        sort(e[i].begin(), e[i].end());
    }

    vector<int> qs(q);
    for (int i = 0; i < q; i++) cin >> qs[i], qs[i]--;
    vector<int> p(q);
    iota(p.begin(), p.end(), 0ll);
    sort(p.begin(), p.end(), [&](int a, int b) {
        return pos[qs[a]] < pos[qs[b]];
    });
    vector<int> gans(qs);

    for (int i = 0; i < q; i++) {
        int v = qs[p[i]];

        int ans = pos[v];

        for (int i : g[0]) {
            int w = lower_bound(e[i].begin(), e[i].end(), pos[v]) - e[i].begin();
            if (w < e[i].size() && w == pos[v]) continue;
            ans = min(ans, pos[v] - w);
        }

        gans[p[i]] = ans;
    }

    for (int i = 0; i < q; i++) {
        cout << gans[i] << '\n';
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//     cin >> t;
    while (t--)
        solve(), cout << '\n';
}
