//author: лелутик :3
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <time.h>
#include <cmath>
#include <cassert>
#include <random>
using namespace std;
#define int long long
#define line cout << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ppb pop_back
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pii pair<int, int>
const int MAXN = 3e5 + 10;
int p[MAXN], s[MAXN];
vector<int> g[MAXN];
int num[MAXN];
int dp[MAXN];
int tin[MAXN], tout[MAXN];
int t = 1;

void dfs2(int v) {
    tin[v] = t++;
    for (auto &u : g[v]) {
        dfs2(u);
    }
    tout[v] = t++;
}


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


void dfs(int v, int x) {
    if (num[v] >= x) {
        return;
    }
    dp[v] = 1;
    for (auto &u : g[v]) {
        dfs(u, x);
        dp[v] += dp[u];
    }
}


int deep[MAXN];

void dfs3(int v, int h) {
    deep[v] = h;
    for (auto &u : g[v]) {
        dfs3(u, h + 1);
    }
}

void solve() {
    int n, q;
    cin >> n >> q;
    int calc = 0;
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        calc += (p[i] == 0);
        g[p[i]].pb(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int cur = 0, cnt = 0;
    set<pii> smezh;
    for (auto &u : g[0]) {
        smezh.insert({s[u], u});
    }
    while (1) {
        num[cur] = cnt;
        cnt++;
        if (sz(smezh) == 0) {
            break;
        }
        auto it = --smezh.end();
        int v = it->second;
        smezh.erase(it);
        for (auto &u : g[v]) {
            smezh.insert({s[u], u});
        }
        cur = v;
    }
    dfs3(0, 0);
    if (calc == 1) {
        while (q--) {
            int v;
            cin >> v;
            cout << deep[v - 1] << " ";
        }
        line;
        return;
    } else {
        assert(0);
        vector<int> num1(n), num2(n);
        // left
        set<pii> smezh;
        int val = s[g[0][0]];
        s[g[0][0]] = 0;
        for (auto &u : g[0]) {
            smezh.insert({s[u], u});
        }
        while (1) {
            num1[cur] = cnt;
            cnt++;
            if (sz(smezh) == 0) {
                break;
            }
            auto it = --smezh.end();
            int v = it->second;
            smezh.erase(it);
            for (auto &u : g[v]) {
                smezh.insert({s[u], u});
            }
            cur = v;
        }
        s[g[0][0]] = val;
        // right
        val = s[g[0][1]];
        s[g[0][1]] = 0;
        smezh.clear();
        for (auto &u : g[0]) {
            smezh.insert({s[u], u});
        }
        while (1) {
            num1[cur] = cnt;
            cnt++;
            if (sz(smezh) == 0) {
                break;
            }
            auto it = --smezh.end();
            int v = it->second;
            smezh.erase(it);
            for (auto &u : g[v]) {
                smezh.insert({s[u], u});
            }
            cur = v;
        }
        s[g[0][1]] = val;
        while (q--) {
            int v;
            cin >> v;
            v--;
            cout << min(num1[v], num2[v]) << " ";
        }
        line;
    }
}

signed main() {
    fast;


#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}