#include #define rep(i,n) for(ll i=0;i>N>>M; vector V(N); vector R(M); sort(V.begin(),V.end()); sort(R.begin(),R.end()); rep(i,N) cin>>V[i]; rep(i,M) cin>>R[i]; ll A,B; cin>>A>>B; vector> dp_v(N+1,vector(N*MAX_VR+1,0)); vector> dp_r(M+1,vector(M*MAX_VR+1,0)); dp_v[0][0]=1; dp_r[0][0]=1; rep(i,N) { for(ll j=N*MAX_VR-V[i];j>=0;j--) { dp_v[i+1][j]+=dp_v[i][j]; dp_v[i+1][j]%=MOD; dp_v[i+1][j+V[i]]+=dp_v[i][j]; dp_v[i+1][j+V[i]]%=MOD; } } rep(i,M) { for(ll j=M*MAX_VR-R[i];j>=0;j--) { dp_r[i+1][j]+=dp_r[i][j]; dp_r[i+1][j]%=MOD; dp_r[i+1][j+R[i]]+=dp_r[i][j]; dp_r[i+1][j+R[i]]%=MOD; } } vector alloc(N*MAX_VR+2,0); rep(i,N*MAX_VR+1) { alloc[i+1]=alloc[i]+dp_v[N][i]; alloc[i+1]%=MOD; } ll ans=0; for(ll i=1;i<=M*MAX_VR;i++) { ll max=B*i; ll min=A*i; if(min>N*MAX_VR)break; if(max>N*MAX_VR)max=N*MAX_VR; ans+=((alloc[max+1]-alloc[min]+MOD)%MOD)*dp_r[M][i]; ans%=MOD; } cout<