#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;
using ll = long long;
using ld = long double;

//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template<typename T>
//using oset = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;

// #define int ll

vector<vector<int>> graph;
vector<int> p, s, clr;
vector<vector<int>> places;

void dfs(int start) {
    for (auto child : graph[start])
        dfs(child);

    places[start].push_back(clr[start]);
    for (auto child : graph[start])
        for (auto el : places[child])
            places[start].push_back(el);

    std::sort(places[start].begin(), places[start].end());
}

signed main() {
    int n, q;
    cin >> n >> q;

    p.resize(n);
    s.resize(n);
    clr.resize(n);
    graph.resize(n);
    places.resize(n);

    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        graph[p[i]].push_back(i);
    }

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

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

    int ci = 0;
    while (not st.empty()) {
        int now = st.begin()->second;
        st.erase(st.begin());
        clr[now] = ci++;

        for (auto child : graph[now]) {
            st.insert({-s[child], child});
        }
    }

    dfs(0);

    int v;
    for (int _ = 0; _ < q; ++_) {
        cin >> v;
        v--;

        int res = clr[v];
        for (int i = 0; i < n; ++i) {
            auto px = std::lower_bound(places[i].begin(), places[i].end(), clr[v]);
            if (px == places[i].end() or  *px != clr[v])
                res = min(res, int(clr[v] - (px - places[i].begin())));
        }
        cout << res << ' ';
    }
}
