#include "bits/extc++.h"

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

template<typename T>
istream &operator>>(istream &is, vector<T> &a);

template<typename T>
ostream &operator<<(ostream &os, vector<T> &a);


using ordered_set = tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
vector<int> s;


signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    ll n, q;
    cin >> n >> q;

    vector<vector<int>> g(n);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        p--;

        g[p].push_back(i);
    }

    s.resize(n);
    cin >> s;

    struct Comp {
        const bool operator()(int l, int r) const {
            return s[l] > s[r];
        }
    };

    vector<int> best(n,1e9);
    for (int del = 0; del < n; ++del) {
        int old = s[del];
        s[del] = 0;
        vector<set<int, Comp>> g2(n);
        for (int v = 0; v < n; ++v) {
            for (auto u: g[v]) {
                g2[v].insert(u);
            }
        }

        vector<int> time(n);
        int root = 0;
        for (int i = 0; i < n; ++i) {
            time[root] = i;
            int nxt = *g2[root].begin();
            for (auto u: g2[root]) {
                if (u == nxt) continue;
                g2[nxt].insert(u);
            }
            root = nxt;
        }
        for (int i = 0; i < n; ++i) {
            best[i] = min(best[i], time[i]);
        }

        s[del] = old;
    }
    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;

        cout << best[v-1] << " ";
    }
}

template<typename T>
istream &operator>>(istream &is, vector<T> &a) {
    for (auto &v: a) is >> v;
    return is;
}

template<typename T>
ostream &operator<<(ostream &os, vector<T> &a) {
    for (auto v: a) os << v << " ";
    return (os << "\n");
}
