//author: лелутик :3
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <time.h>
#include <cmath>
#include <cassert>
#include <random>
using namespace std;
#define int long long
#define line cout << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ppb pop_back
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pii pair<int, int>
const int MAXN = 2e5 + 10;
int p[MAXN], s[MAXN];


void solve() {
    int n, q;
    cin >> n >> q;
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        if (v == 0) {
            cout << 0 << " ";
            continue;
        }
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] > s[v]) {
                cnt++;
            }
        }
        cout << max(1ll, cnt - 1) << " ";
    }
}

signed main() {
    fast;


#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


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