#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <array>
#include <unordered_set>
using namespace std;
typedef long long ll;
const ll Inf = 1e16;
/*struct SegmentTree {
    struct Node {
        ll sm;
        Node(ll a = 0) { sm = a; }
    };
    vector<Node>tree; ll n;
    SegmentTree(vector<ll>& a) {
        n = a.size(); tree.resize(4 * n);
        build(0, 0, n, a);
    }
    void build(ll v, ll l, ll r, vector<ll>&a) {
        if (r - l == 1) {
            tree[v] = Node(a[l]); return;
        }
        ll mid = (l + r)/2;
        build(2 * v + 1, l, mid, a);
        build(2 * v + 2, mid, r, a);
        tree[v] = merge(tree[2 * v + 1], tree[2 * v + 2]);
    }
    Node merge(Node&a, Node&b) {
        return Node(a.sm + b.sm);
    }
    Node get(ll v, ll l, ll r, ll ind) {
        if (r - l == 1)return tree[v];

    }
};*/
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    ll n, q; cin >> n >> q;
    array<ll, 1000>p;
    for (int i = 1; i < n; i++) {
        ll x; cin >> x; p[i] = x - 1;
    }
    array<ll, 1000>s; array<ll,1000>ans;
    for (int i = 0; i < n; i++)cin >> s[i];
    array<set<pair<ll,ll>>, 1000>g;
    for (int i = 1; i < n; i++) {
        g[p[i]].insert({ s[i], i });
    }
    for (int V = 0; V < n; V++) {
        auto G = g;
        ll st = s[V]; s[V] = 0;
        if (V != 0) {
            G[p[V]].erase({ st, V });
            G[p[V]].insert({ 0, V });
        }
        array<ll, 1000>m;
        ll v = 0, ind = 0, cnt = 0;
        while (1) {
            m[v] = ind; ind++;
            if (G[v].size() == 0)break;
            auto P = *G[v].rbegin(); cnt += 2;
            G[v].erase(P); ll u = P.second;
            for (auto [x, y] : G[v]) {
                cnt++;
                G[u].insert({ x, y });
            }
            v = u;
        }
        for (int i = 0; i < n; i++) {
            if (V == 0)ans[i] = m[i];
            ans[i] = min(ans[i], m[i]);
        }
        s[V] = st;cout << cnt << endl;
    }
    while (q--) {
        ll v; cin >> v; v--;
        cout << ans[v] << " ";
    }

}