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

#define int long long
using namespace std;
using namespace __gnu_pbds;
int n;
vector<int> p, s;
vector<vector<int>> gr;
bool comp(int i, int j) {
    return s[i] > s[j];
}
vector<int> sz;
vector<int> ans;
vector<int> tin, tout;
int tme = 0;
void calc_sz(int v) {
    sz[v] = 1;
    tin[v] = tme++;
    for (auto x : gr[v]) {
        calc_sz(x);
        sz[v] += sz[x];
    }
    tout[v] = tme;
}
bool a(int u, int v) {

    return tin[u] <= tin[v] && tin[v] < tout[u];
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int q; cin >> n >> q;
    p.resize(n);
    gr.resize(n);
    sz.resize(n);
    tin.resize(n);
    tout.resize(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        gr[p[i]].push_back(i);
    }
    ans.resize(n);
    s.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        sort(gr[i].begin(), gr[i].end(), comp);
    }
    calc_sz(0);
   // dfs(0);
   vector<int> z;
   vector<int> z2;
   for (int i = 1; i < n; i++) {
       if (i != gr[0][0]) {
           z.push_back(i);
       }
   }
   if (gr[0].size() > 1) {
       for (int i = 1; i < n; i++) {
           if (i != gr[0][1] && i != gr[0][0]) z2.push_back(i);
       }
   }
    while (q--) {
       int u; cin >> u; u--;
       if (u == 0) cout << 0 << ' ';
       else if (gr[0][0] == u || (gr[0].size() > 1 && gr[0][1] == u)) {
           cout << 1 << ' ';
       }  else {
           int cnt = 0;
           for (auto x : z) {
               if (s[x] >= s[u]) cnt++;
           }
           int cnt2 = n + 5;
           if (gr[0].size() > 1) {
               cnt2 = 1;
               for (auto x : z2) {
                   if (s[x] >= s[u]) cnt2++;
               }
           }
           cout << max(2ll, cnt) << ' ';
       }
    }
    return 0;
}
