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

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using o_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;

//find_by_order()
//order_of_key()

int n, q;

vector<vector<int>> g;
vector<int> p, s, min1, pos, pos1, d;
vector<bool> f;

void dfs(int v, bool f1, int cur = 0) {
    d[v] = d[p[v]] + 1;
    f[v] = f1;
    if (f1) {
        pos[s[v]] = min(pos[s[v]], cur);
    } else {
        pos1[s[v]] = min(pos1[s[v]], cur);
    }
    min1[v] = min(min1[p[v]], s[v]);
    for (auto to : g[v]) {
        if (to != p[v]) {
            dfs(to, f1, cur++);
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> q;
    g.resize(n);
    p.reserve(n);
    s.resize(n);
    min1.resize(n, 1e9);
    pos.resize(n + 1, 1e9);
    pos1.resize(n + 1, 1e9);
    d.resize(n, 0);
    f.resize(n);
    p[0] = -1;
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[i].push_back(p[i]);
        g[p[i]].push_back(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    bool f1 = true;
    for (auto to : g[0]) {
        dfs(to, f1);
        if (f1) {
            f1 = false;
        }
    }
    for (int i = 1; i <= n; i++) {
        pos[i] = min(pos[i], pos[i - 1]);
        pos1[i] = min(pos1[i], pos1[i - 1]);
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        if (f[v]) {
            cout << d[v] + pos1[s[v]] << ' ';
        } else {
            cout << d[v] + pos[s[v]] << ' ';
        }
    }
    return 0;
}
