#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long v[110000] = {}, r[110000] = {}; long long const mod = 1000000007; long long const mx = 100010; int main() { long long n, m, a, b; cin >> n >> m; v[0] = 1, r[0] = 1; for (int i = 0; i < n; i++) { int vi; cin >> vi; for (int j = mx; j >= vi; j--) { v[j] += v[j - vi]; v[j] %= mod; } } for (int i = 0; i < m; i++) { int ri; cin >> ri; for (int j = mx; j >= ri; j--) { r[j] += r[j - ri]; r[j] %= mod; } } cin >> a >> b; long long ans = 0; for (int i = 1; i < mx; i++) { v[i] += v[i - 1]; v[i] %= mod; } for (int i = 1; i < mx; i++) { ans += r[i] * (v[min(i * b, mx)] - v[min(i * a - 1, mx)]) % mod; ans %= mod; } cout << (ans + mod) % mod << endl; }