#include <bits/stdc++.h>

#define int long long
using namespace std;

const int INF = 2e16;

vector<vector<int>> g;
vector<pair<int,int>> l;
vector<int> s, ans;

bool cmp(int a, int b) {
    return s[a] < s[b];
}

signed main() {
    int n, q;
    cin >> n >> q;
    s.resize(n);
    ans.resize(n);
    l.resize(n);
    vector<int> last, all, last_i;
    ans[0] = 0;
    for (int i = 1; i < n; i++) {
        all.push_back(i);
    }
    for (int i = 1; i <= n - 1; i++) {
        int x;
        cin >> x;
        x--;
        if (x == 1) {
            if ((int)last.size() != 0) {
                g.push_back(last);
                last.clear();
            }
        }
        l[i].first = (int)g.size();
        l[i].second = (int)all.size();
        last.push_back(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    set<pair<int,int>> d;
    for (int i = 0; i < g.size(); i++) {
        last_i.push_back((int)g[i].size);
        d.insert({last_i[i], i});
    }
    sort(all.begin(), all.end(), cmp);
    int cnt = n - 1;
    for (int i = 1; i < n; i++) {
        ans[i] = 1 + cnt - d.rbegin()->first;
        int ind1 = l[i].first, ind2 = l[i].second;
        d.erase({last_i[ind1], ind1});
        cnt -= last_i[ind1] - ind2;
        last_i[ind1] = ind2;
        d.insert({last_i[ind1], ind1});
    }
    while (q--) {
        int x;
        cin >> x;
        x--;
        cout << ans[x] << " ";
    }
}