#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;

template<typename T>
istream& operator>>(istream& in, vector<T>& v) {
    for (T& x : v) in >> x;
    return in;
}

template<typename T>
ostream& operator<<(ostream& out, vector<T>& v) {
    for (T& x : v) out << x << " ";
    return out;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
    in >> p.first >> p.second;
    return in;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& p) {
    out << p.first << " " << p.second;
    return out;
}

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
using ld = long double;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

struct fenwick {

    fenwick() {}
    fenwick(int n) : n(n) {
        v.resize(n);
    }

    void add(int r, int x) {
        for (; r < n; r = r | (r + 1)) v[r] += x;
    }

    int get(int r) {
        int s = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1) s += v[r];
        return s;
    }

    int get(int l, int r) {
        return get(r) - get(l - 1);
    }

    int n;
    vector<int> v;

};

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> p(n);
    vector<vector<int>> g(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    vector<int> a(n), qr(q);
    cin >> a >> qr;
    for (int& x : qr) x--;

    vector<int> ord, pos(n);
    {
        set<pair<int, int>> s;
        s.emplace(a[0], 0);
        while (!s.empty()) {
            int i = prev(s.end())->second;
            pos[i] = ord.size();
            s.erase(prev(s.end()));
            ord.push_back(i);
            for (int to : g[i]) s.emplace(a[to], to);
        }
    }

    for (int id = 0; id < q; id++) {
        int i = qr[id];
        vector<int> cnt(n);
        int ans = pos[i];
        auto dfs = [&](auto dfs, int v) -> bool {
            if (pos[v] < pos[i]) cnt[v]++;
            bool is = false;
            for (int to : g[v]) {
                is |= dfs(dfs, to);
                cnt[v] += cnt[to];
            }
            if (v == i) is = true;
            if (!is) ans = min(ans, pos[i] - cnt[v]);
            return is;
        };
        dfs(dfs, 0);
        cout << ans << "\n";
    }
}

signed main() {
#ifndef LOCAL
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
#endif

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