#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const long long int MOD = 1e9 + 7; int V[100]; int R[100]; int A, B; int n, m; long long int dp1[2][100005]; long long int dp2[2][100005]; long long int res = 0; long long int psum[100005]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; for (int i = 0; i < n; i++) { cin >> V[i]; } for (int i = 0; i < m; i++) { cin >> R[i]; } cin >> A >> B; dp1[1][0] = 1; dp2[1][0] = 1; for (int i = 0; i < n; i++) { memcpy(dp1[0], dp1[1], sizeof(dp1[1])); memset(dp1[1], 0, sizeof(dp1[1])); for (int j = 100000; j >= 0; j--) { if (dp1[0][j] == 0) { continue; } dp1[1][j] = ((dp1[1][j] % MOD) + (dp1[0][j] % MOD) % MOD); dp1[1][j] %= MOD; if (j + V[i] <= 100000) { dp1[1][j + V[i]] = ((dp1[1][j + V[i]] % MOD) + (dp1[0][j] % MOD) % MOD); dp1[1][j + V[i]] %= MOD; } } } for (int i = 0; i < m; i++) { memcpy(dp2[0], dp2[1], sizeof(dp2[1])); memset(dp2[1], 0, sizeof(dp2[1])); for (int j = 100000; j >= 0; j--) { if (dp2[0][j] == 0) { continue; } dp2[1][j] = ((dp2[1][j] % MOD) + (dp2[0][j] % MOD) % MOD); dp2[1][j] %= MOD; if (j + R[i] <= 100000) { dp2[1][j + R[i]] = ((dp2[1][j + R[i]] % MOD) + (dp2[0][j] % MOD) % MOD); dp2[1][j + R[i]] %= MOD; } } } psum[0] = 0; for (int i = 1; i <= 100000; i++) { psum[i] = ((psum[i - 1] % MOD) + (dp1[1][i] % MOD) % MOD); psum[i] %= MOD; } for (long long int j = 1; j <= 100000; j++) { if (dp2[1][j] == 0) { continue; } long long int L = A * j; long long int R = B * j; R = min(R, 100000LL); if (L > 100000) { L = 100001; } long long int val = psum[R] - psum[L - 1]; //cout << L << ' ' << R << ' ' << j << '\n'; val %= MOD; if (val < 0) { val += MOD; } res = ((res % MOD) + ((val % MOD) * (dp2[1][j] % MOD) % MOD) % MOD); res %= MOD; } cout << res << '\n'; return 0; }