#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ll i,j,n,q;
    cin>>n>>q;
    vector<ll>cmp(n);
    ll cnt=0;
    vector<vector<ll>>m(2);
    vector<ll>pos(n);
    for (i=1;i<n;i++){
        ll p;
        cin>>p;
        if (p==1){
            cmp[i]=cnt;
            cnt++;
        }
        else{
            cmp[i]=cmp[i-1];
        }
        m[cmp[i]].push_back(i);
        pos[i]=m[cmp[i]].size()-1;
    }
    vector<ll>s(n);
    for (i=0;i<n;i++){
        cin>>s[i];
    }
    ll cand=1e9;
    for (i=0;i<m[0].size();i++){
        m[0][i]=min(m[0][i],cand);
        cand=min(cand,m[0][i]);
    }
    cand=1e9;
    for (i=0;i<m[1].size();i++){
        m[1][i]=min(m[1][i],cand);
        cand=min(cand,m[1][i]);
    }
    while (q--){
        ll q1;
        cin>>q1;
        q1--;
        if (q1==0){
            cout<<0<<'\n';
        }
        else{
            cout<<pos[q1]+1<<'\n';
        }
    }
    return 0;
}