#include int ri() { int n; scanf("%d", &n); return n; } #define MOD 1000000007 int main() { int n = ri(), m = ri(); int a[n], b[m]; for (auto &i : a) i = ri(); for (auto &i : b) i = ri(); int x = ri(), y = ri(); int dp0[100001]; memset(dp0, 0, sizeof(dp0)); dp0[0] = 1; auto add = [&] (int &a, int b) { a += b; if (a >= MOD) a -= MOD; }; for (auto i : a) for (int j = 100000 - i; j >= 0; j--) add(dp0[j + i], dp0[j]); int dp1[100001]; memset(dp1, 0, sizeof(dp1)); dp1[0] = 1; for (auto i : b) for (int j = 100000 - i; j >= 0; j--) add(dp1[j + i], dp1[j]); dp0[0] = dp1[0] = 0; int sum[100002]; memset(sum, 0, sizeof(sum)); for (int i = 0; i <= 100000; i++) sum[i + 1] = sum[i], add(sum[i + 1], dp0[i]); int res = 0; for (int i = 0; i <= 100000; i++) { int64_t lower = (int64_t) i * x; int64_t upper = std::min((int64_t) i * y + 1, 100001); if (lower <= 100000) add(res, (int64_t) (sum[upper] - sum[lower]) * dp1[i] % MOD); } printf("%d\n", res); return 0; }