#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 = 1005;
vector<int> g[maxn];
int s[maxn];

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

    while (q--) {
        int v;
        cin >> v;
        v--;
        int posv = pos[v];

        int ans = posv;

        for (int i = 1; i < n; i++) {
            int w = lower_bound(e[i].begin(), e[i].end(), posv) - e[i].begin();
            if (w < e[i].size() && e[i][w] == posv) continue;
            ans = min(ans, posv - w);
        }

        cout << ans << '\n';
    }
}

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

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