#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <chrono>
using namespace std;
using ll = long long;
using lld = long double;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

vector<int> f(vector<vector<ll>>& g, vector<ll>& s) {
    vector<int> ans;
    set<pair<ll, ll>> q;
    q.insert({-s[0], 0});
    while (!q.empty()) {
        ll k = (*q.begin()).second;
        ans.push_back(k);
        q.erase(q.begin());
        for (auto el : g[k]) {
            q.insert({-s[el], el});
        }
    }
    return ans;
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif;
    ll n, q;
    cin >> n >> q;
    vector<vector<ll>> g(n);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }
    vector<ll> s(n);
    for (int i = 0; i < n; ++i)
        cin >> s[i];
    vector<int> pos(n, 1e7);
    for (int i = 0; i < n; ++i) {
        ll x = s[i];
        s[i] = 0;
        vector<int> d = f(g, s);
        s[i] = x;
        for (int j = 0; j < (int)d.size(); ++j) {
            pos[d[j]] = min(pos[d[j]], j);
        }
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        cout << pos[v] << " ";
    }
}