#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
using ll = long long;

typedef tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int inf = 1e9 + 7;
const ll inf_ = 1e18 + 7;
const int mod = 998244353;

struct Fast {
    vector<vector<int>> g;
    vector<int> s;
    vector<int> ans;

    void solve() {
        int n, q;
        cin >> n >> q;
        g.resize(n);
        for (int i = 1; i < n; i++) {
            int x;
            cin >> x;
            x--;
            g[x].push_back(i);
        }
        s.resize(n);
        ans.resize(n, inf);
        for (auto &i: s) cin >> i;
        for (int v = 1; v < n; v++) {
            int pr = s[v];
            s[v] = 0;
            set<pair<int, int>> t;
            for (auto u: g[0]) t.insert({s[u], u});
            int ind = 1;
            int root = 0;
            ans[root] = min(ans[root], ind);
            while (!t.empty()) {
                ans[root] = min(ans[root], ind);
                root = (--t.end())->second;
                t.erase(--t.end());
                for (auto u: g[root]) t.insert({s[u], u});
                ind++;
            }
            s[v] = pr;
        }
        while (q--) {
            int x;
            cin >> x;
            x--;
            cout << ans[x] - 1 << ' ';
        }
    }
};

signed main() {
    int __ = 1;
    //cin >> __;
    while (__--) {
        Fast().solve();
        cout << '\n';
    }
    return 0;
}
