#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <ctime>
#include <random>
#include <map>
#include <set>
#define ll long long
#define nl '\n'
#define emp emplace_back
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define pii pair<int, int>
#define popcnt __builtin_popcount
#define ffs __builtin__ffs
#define ss second
#define ff first
//#include <ext/pb_ds/assoc_container.hpp>
//#pragma GCC optimize("O3")
//#pragma GCC target("avx");
//#pragma GCC target("avx2");

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll INF = 1e9;

const ll mod = 998244353;

mt19937 rnd(time(nullptr));

template<typename T>
istream &operator >>(istream &in, vector<T> &arr) {
    for (auto &x : arr) {
        in >> x;
    }
    return in;
}

template<typename T>
ostream &operator <<(ostream &out, vector<T> &arr) {
    for (auto &x : arr) {
        out << x << ' ';
    }
    out << '\n';
    return out;
}

int n, q;
vector<vector<int>> g;
vector<int> s;
vector<int> start;

int check(int i, int ind) {
    int last = s[i];
    s[i] = 0;
    set<pii> st;
    for (auto u : g[0]) {
        st.insert({s[u], u});
    }
    vector<int> dist(n, INF);
    dist[0] = 0;
    int t = 1;
    while (!st.empty()) {
        auto it = --st.end();
        int u = it->ss;
        dist[u] = t++;
        st.erase(it);
        for (auto v : g[u]) {
            st.insert({s[v], v});
        }
    }
    s[i] = last;
    if (i == n) {
        start = dist;
    }
    return dist[ind];
}

void solve() {
    cin >> n >> q;
    g.resize(n);
    s.resize(n);
    vector<int> pr(n, -1);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        pr[i] = p;
        g[p].emp(i);
    }
    cin >> s;
    s.emp(0);
    check(n, 0);
    while (q--) {
        int x;
        cin >> x;
        --x;
        int ans = start[x];
        vector<int> ind;
        while (x != -1) {
            ind.emp(x);
            x = pr[x];
        }
        reverse(all(ind));
        for (int i = 0; i < (int)ind.size() - 1; ++i) {
            int u = ind[i];
            for (auto v : g[u]) {
                if (v == ind[i + 1]) continue;
                ans = min(ans, check(v, ind.back()));
            }
        }
        cout << ans << ' ';
    }
}

int main() {
#ifdef CLOCK
    ll time1 = clock();
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll tpk = 1;

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

    while (tpk--) {
        solve();
        cout << nl;
    }

#ifdef CLOCK
    cout << clock() - time1 << " ms";
#endif
}