#include <bits/stdc++.h>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<pair<int, int>>;
using vc = vector<char>;
using vb = vector<bool>;
template<typename T>
using ve = vector<T>;
template<typename T1, typename T2>
using pr = pair<T1, T2>;

const int INF = 1e9 + 1;
const long long INFLL = 1e18 + 1;
const int MOD = 1e9 + 7;

inline void fchmin(int &a, int &b) { a = min(a, b); }
inline void fchmax(int &a, int &b) { a = max(a, b); }

template<typename T>
inline bool chmin(T &a, T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
inline bool chmax(T &a, T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

// #include<ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

int reps = 1;

ve<vi> g;

vi s;
vi tin, tout;
int T = 0;

void dfs(int v, int p) {
    tin[v] = T++;
    for (auto u : g[v]) {
        if (p != u) dfs(u, v);
    }
    tout[v] = T;
}

bool is_pred(int a, int b) {
    return tin[a] <= tin[b] && tout[a] >= tout[b];
}

struct SegTree {
    int maxn;
    vi st;

    SegTree() {}
    SegTree(vi &a) : maxn(a.size()) {
        st.resize(4 * maxn);
        build(a, 0, 0, maxn);
    }

    void build(vi &a, int v, int l, int r) {
        if (r - l == 1) {
            st[v] = a[l];
            return;
        }
        int mid = (r + l) / 2;
        build(a, 2 * v  + 1, l, mid);
        build(a, 2 * v + 2, mid, r);
        st[v] = min(st[2 * v + 1], st[2 * v + 2]);
    }

    int get(int x) {
        int  l = 0, r = maxn;
        int v = 0;
        while (r - l > 1) {
            int mid = (r + l) / 2;
            if (st[2 * v + 1] < x) {
                r = mid;
                v = 2 * v + 1;
            } else {
                l = mid;
                v = 2 * v + 2;  
            }
        }
        return l;
    }     
};

void solve() {
    int n, q; cin >> n >> q;
    g.clear();
    g.resize(n);
    tin.clear();
    tin.resize(n);
    tout.clear();
    tout.resize(n);
    vi P(n, -1);
    for (int i = 1; i < n; i++) {
        int p; cin >> p; p--;
        P[i] = p;
        // g[i].push_back(p);
        g[p].push_back(i);
    }
    dfs(0, -1);
    s.clear();
    s.resize(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    vi v_min(n, INF);
    vi h(n);
    queue<int> notvis;
    notvis.push(0);
    v_min[0] = INF;
    while (!notvis.empty()) {
        int v = notvis.front();
        notvis.pop();
        for (auto u : g[v]) {
            h[u] = h[v] + 1;
            v_min[u] = min(s[u], v_min[v]);
            notvis.push(u);
        }
    }

    ve<SegTree> sts;
    for (auto u : g[0]) {
        vi cur;
        while ((int)g[u].size() > 0) {
            cur.push_back(s[u]);
            u = g[u][0];
        }
        sts.push_back(SegTree(cur));
    }

    while (q--) {
        int v; cin >> v; v--;
        cout << h[v] << ' ';
    }
    cout << '\n';
}

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

    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin >> reps;
    #endif

    for (int i = 1; i <= reps; i++) {
        #ifdef LOCAL
        cout << "===== Test #" << i << " ========\n";
        #endif
        solve();
        #ifdef LOCAL
        cout << "==== End test =====\n\n";
        #endif
    }
}