#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define fast ios::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main(){
fast
ll n,m;
cin>>n>>m;
vector<ll> a(n),b(m);
for(ll i=0;i<n;i++)cin>>a[i];
for(ll i=0;i<m;i++)cin>>b[i];
sort(all(a));
reverse(all(a));
sort(all(b));
reverse(all(b));
ll q;
cin>>q;
while(q--){
ll k;
cin>>k;
vector<ll> event(n+1,0);
ll add = 0;
ll ans = 0,at = 0;
for(ll i=0;i<n;i++){
add += event[i];
ll cur = add + a[i];
ll need = k - cur;
if(need <= 0){
ans++;
continue;
}
for(ll j=0;j<need && at < m;j++){
event[min(n , i + b[at])]--;
add++;
at++;
}
if(add + a[i] >= k)ans++;
}
cout << ans << ' ';
}
}
/*
1- Look at base case (n=1,m=1)
2- Overflow
3- Use assert
*/
Copy