#ifndef LOCAL
#include <bits/allocator.h>
#pragma GCC optimize("O3,unroll-loops,no-stack-protector")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt,tune=native")
#else
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i128 = __int128_t;

#define all(x) (x).begin(), (x).end()

const int MAX_N = 3e5;

vector<int> graph[MAX_N];
int lvl[MAX_N], queries[MAX_N], par[MAX_N], normal_time[MAX_N];
int tin[MAX_N], tout[MAX_N];

int n, q;

void dfs(int v, int &timer) {
    tin[v] = ++timer;
    for (int x : graph[v]) {
        dfs(x, timer);
    }
    tout[v] = timer;
}

struct SegmentTree2 {
    int len;
    vector<int> tree;

    SegmentTree2(int n) {
        len = __bit_ceil(n);
        tree.resize(len * 2);
    }

    int get(int l, int r) {
        if (l > r) return 0;
        l += len, r += len;
        int res1 = 0, res2 = 0;
        while (l <= r) {
            if ((l & 1) == 1) res1 = max(res1, tree[l++]);
            if ((r & 1) == 0) res2 = max(tree[r--], res2);
            l >>= 1, r >>= 1;
        }
        return max(res1, res2);
    }

    void inc(int i) {
        i += len;
        tree[i]++;
        i >>= 1;
        while (i > 0) {
            tree[i] = max(tree[i * 2], tree[i * 2 + 1]);
            i >>= 1;
        }
    }
};

void solve() {
    cin >> n >> q;
    par[0] = -1;
    int is_not_group2 = false;
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        par[i] = p;
        graph[p].push_back(i);
        is_not_group2 |= p != 0 && p != i - 1;
    }
    for (int i = 0; i < n; ++i) {
        cin >> lvl[i];
    }
    for (int i = 0; i < q; ++i) {
        cin >> queries[i];
        --queries[i];
    }
    priority_queue<pair<int, int>> que;
    que.emplace(0, 0);
    int curr_time = 0;
    while (!que.empty()) {
        int v = que.top().second;
        normal_time[v] = curr_time++;
        que.pop();
        for (int x : graph[v]) {
            que.emplace(lvl[x], x);
        }
    }
    curr_time = -1;
    dfs(0, curr_time);
    vector<int> normal_time_tins(n);
    for (int i = 0; i < n; ++i) {
        normal_time_tins[tin[i]] = normal_time[i];
    }
    vector<int> del_order(n);
    iota(all(del_order), 0);
    sort(all(del_order), [&](int i, int j) {
        return normal_time[i] < normal_time[j];
    });
    vector<int> next_big_ch(n, -1);
    for (int i : del_order) {
        if (i == 0) continue;
        if (graph[par[i]].size() > 1) {
            next_big_ch[i] = i;
        } else {
            next_big_ch[i] = next_big_ch[par[i]];
        }
    }
    SegmentTree2 tree2(n);
    vector<int> answers(n, -1);
    for (int qv : del_order) {
        if (qv == 0) continue;
        int ans = normal_time[qv];
        for (int v = next_big_ch[qv]; v != -1; v = next_big_ch[par[v]]) {
            if (v == 0)
                break;
            tree2.inc(tin[v]);
            int subtree_cnt = max(tree2.get(tin[par[v]] + 1, tin[v] - 1), tree2.get(tout[v] + 1, tout[par[v]]));
            ans = min(ans, normal_time[qv] - subtree_cnt);
            if (par[v] == -1) {
                break;
            }
        }
        answers[qv] = ans;
    }
    answers[0] = 0;
    for (int qi = 0; qi < q; ++qi) {
        cout << answers[queries[qi]] << " ";
    }
    cout << "\n";
}

int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}