// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")

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

// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#ifdef LOCAL
    #define debug(x) cout << #x << ": " << x << endl;
#else
    #define debug(x)
#endif
#define mt_seed chrono::high_resolution_clock::now().time_since_epoch().count()
#define time_now chrono::high_resolution_clock::now()
#define time_res(s, f) chrono::duration_cast<chrono::nanoseconds>(f - s).count()
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define file_in freopen("input.txt", "r", stdin);
#define file_out freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define pb push_back
#define ff first
#define sc second
#define int ll

using namespace std;
using namespace __gnu_pbds;

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using str = string;
using pii = pair<int, int>;
using ordered_set = tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T1, typename T2> istream& operator>>(istream &in, pair<T1, T2> &a) { in >> a.ff >> a.sc; return in; }
#ifdef LOCAL
    template<typename T1, typename T2> ostream& operator<<(ostream &out, const pair<T1, T2> &a) { out << "{" << a.ff << ' ' << a.sc << "}"; return out; }
#else
    template<typename T1, typename T2> ostream& operator<<(ostream &out, const pair<T1, T2> &a) { out << a.ff << ' ' << a.sc; return out; }
#endif
template<typename T> istream& operator>>(istream &in, vector<T> &a) { for (auto &el : a) in >> el; return in; }
template<typename T> ostream& operator<<(ostream &out, const vector<T> &a) { for (auto &el : a) out << el << " "; return out; }
template<typename T> ostream& operator<<(ostream &out, const set<T> &a) { for (auto &el : a) out << el << " "; return out; }
template<typename T> ostream& operator<<(ostream &out, const multiset<T> &a) { for (auto &el : a) out << el << " "; return out; }
template<typename T, typename comp> ostream& operator<<(ostream &out, const unordered_set<T, comp> &a) { for (auto &el : a) out << el << " "; return out; }
template<typename T> T max(T a, T b, T c) { return max(a, max(b, c)); }
template<typename T> T max(T a, T b, T c, T d) { return max(max(a, b), max(c, d)); }
template<typename T> T min(T a, T b, T c) { return min(a, min(b, c)); }
template<typename T> T min(T a, T b, T c, T d) { return min(min(a, b), min(c, d)); }
const ll LOL = mt_seed;
mt19937_64 genom(LOL); ll randint(ll l, ll r) { uniform_int_distribution<ll> random_distrib_2_0(l, r); return random_distrib_2_0(genom); }
const ll RANDOM = genom(); struct chash { ll operator()(ll x) { return x ^ RANDOM; } };

vector<vector<int>> g;
vector<int> s;

vector<int> ord;
void getOrd() {
    ord.clear();
    set<pii> st;
    st.insert({-s[0], 0});
    while (!st.empty()) {
        int v = st.begin()->sc;
        ord.pb(v);
        st.erase(st.begin());
        for (auto to : g[v]) {
            st.insert({-s[to], to});
        }
    }
}

int timer = 0;
vector<int> tin, tout;

void precalc(int v) {
    tin[v] = timer++;
    for (auto to : g[v]) {
        precalc(to);
    }
    tout[v] = timer;
}

bool isAnc(int v, int u) { return tin[v] <= tin[u] && tout[u] <= tout[v]; }

struct fen_tree {
    int n;
    vector<int> t;
    fen_tree(int _n) {
        n = _n;
        t.resize(n + 1);
    }

    void upd(int k, int x) {
        ++k;
        for (; k <= n; k += k & -k)
            t[k] += x;
    }

    int get(int l, int r) { return get(r + 1) - get(l); }
    int get(int x) {
        int res = 0;
        for (; x > 0; x -= x & -x)
            res += t[x];
        return res;
    } 
};

signed main() {
    fast
#ifdef LOCAL
    file_in
#endif

    int n, q;
    cin >> n >> q;
    vector<int> p(n - 1);
    tin.resize(n);
    tout.resize(n);
    s.resize(n);
    cin >> p >> s;

    for (auto &el : p) --el;

    g.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        g[p[i]].pb(i + 1);
    }
    precalc(0);

    vector<int> v(q);
    cin >> v;

    set<int> yas;
    for (auto el : v) yas.insert(el);

    vector<int> ans(n);

    fen_tree t(n);

    getOrd();
    int id = -1;
    for (auto v : ord) {
        ++id;
        t.upd(tin[v], 1);

        if (yas.find(v) != yas.end()) {
            int sz = 0;
            for (int i = 0; i < n; ++i) {
                if (!isAnc(i, v)) {
                    sz = max(sz, t.get(tin[i], tout[i]));
                }
            }
            ans[v] = id - sz;
        }
    }

    for (int i = 0; i < q; ++i) {
        cout << ans[v[i]] << ' ';
    }

    return 0;
}
