#include #define rep(i,n) for(int 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]; int 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(int j=N*MAX_VR-V[i];j>=0;j--) { dp_v[i+1][j]+=dp_v[i][j]; dp_v[i+1][j+V[i]]+=dp_v[i][j]; dp_v[i+1][j]%=MOD; } } rep(i,M) { for(int j=M*MAX_VR-R[i];j>=0;j--) { dp_r[i+1][j]+=dp_r[i][j]; dp_r[i+1][j+R[i]]+=dp_r[i][j]; dp_r[i+1][j]%=MOD; } } vector alloc(N*MAX_VR+2,0); rep(i,N*MAX_VR+1) { alloc[i+1]=alloc[i]+dp_v[N][i]; } ll ans=0; for(int i=1;i<=M*MAX_VR;i++) { int max=B*i; if(max>N*MAX_VR)max=N*MAX_VR; int min=A*i; if(min>N*MAX_VR)min=N*MAX_VR; ans+=(alloc[max+1]-alloc[min])*dp_r[M][i]; ans%=MOD; } cout<