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

struct node {
    int mx;
    int id;
};

struct tree {
    int n;
    vector<node> t;

    tree(int N) : n(N) {
        t.resize(4 * n, {-10000000, 0});
    }
    node merge(node a, node b) {
        if (a.mx > b.mx) return a;
        return b;
    }
    void upd(int v, int l, int r, int pos, ll x) {
        if (r - l == 1) {
            t[v] = {x, l};
            return;
        }
        int m = ((r + l)>>1);
        if (pos < m) upd(2 * v + 1, l, m, pos, x);
        else upd(2 * v + 2, m, r, pos, x);
        t[v] = merge(t[2 * v + 1], t[2 * v + 2]);
    }
    node get_ans(int v, int l, int r, int ql, int qr) {
        if (ql <= l && r <= qr) {
            return t[v];
        }
        if (r <= ql || qr <= l) {
            return {-10000000, 0};
        }
        int m = ((r + l)>>1);
        return merge(get_ans(2 * v + 1, l, m, ql, qr), get_ans(2 * v + 2, m, r, ql, qr));
    }
};




void solve() {
    int n, q; cin >> n >> q;
    int k = 0;
    vector<int> b, nac;

    for (int i = 1; i < n; ++i) {
        int x; cin >> x;
        if (x == 1) {
            k++;
            b.push_back(i);
            nac.push_back(i);
        }
    }
    vector<int> c(n);
    vector<pair<int, int>> Q(n, {0,-1});
    vector<int> ans(n);
    for (int i = 0; i < n; ++i) cin >> c[i];

    tree tr(k);
    for (int i = 0; i < k; ++i) {
        tr.upd(0, 0, n, i, c[b[i]]);
    }
    for (int i = 1; i < n; ++i) {
        node r = tr.get_ans(0, 0, k, 0, k);
        //cout << r.id << ' ' << b[r.id] << '\n';
        b[r.id] ++;
        if ((r.id < k-1 && b[r.id] == nac[r.id + 1]) || b[r.id] == n) {
            tr.upd(0, 0, n, r.id, 0);
        } else {
            tr.upd(0, 0, n, r.id, c[b[r.id]]);
        }
        //cout << r.mx << ' ' << r.id << '\n';
        Q[i] = {b[r.id]-1, r.id};
    }
    map<int, int> mp;
    pair<int, int> mx1= {0, 0}, mx2 = {0,0};
    for (int i = 1; i < n; ++i) {
        auto [u, v] = Q[i];
        //cout << u << ' ' << v << '\n';
        mp[v] ++;
        if (mp[v] > mx2.first) {
            mx2 = {mp[v], v};
        }
        if (mx2.first > mx1.first) {
            swap(mx2, mx1);
        }
        if (mx1.second != v) {
            ans[u] = i - mx1.first;
        } else {
            ans[u] = i - mx2.first;
        }
    }

    while (q--) {
        int x; cin >> x;
        cout << ans[x-1] << '\n';
    }
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

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