fun main() { val builder = StringBuilder() val mod = 1000000007L val (n, m) = readInputLine().split(" ").map { it.toInt() } val vCnt = Array(n) { LongArray(100000 + 1) } val rCnt = Array(m) { LongArray(100000 + 1) } readInputLine().split(" ").forEachIndexed { index, s -> val v = s.toInt() if (index != 0) { for (i in 1..(100000 - v)) { vCnt[index][i] = (vCnt[index][i] + vCnt[index - 1][i]) % mod vCnt[index][i + v] = (vCnt[index][i + v] + vCnt[index - 1][i]) % mod } } vCnt[index][v] = (vCnt[index][v] + 1) % mod } readInputLine().split(" ").forEachIndexed { index, s -> val r = s.toInt() if (index != 0) { for (i in 1..(100000 - r)) { rCnt[index][i] = (rCnt[index][i] + rCnt[index - 1][i]) % mod rCnt[index][i + r] = (rCnt[index][i + r] + rCnt[index - 1][i]) % mod } } rCnt[index][r] = (rCnt[index][r] + 1) % mod } val (a, b) = readInputLine().split(" ").map { it.toLong() } var ans = 0L val vCntSum = LongArray(100000 + 1) for (i in 1..100000) { vCntSum[i] = vCnt[n - 1][i] } for (i in 1..100000) { vCntSum[i] = (vCntSum[i] + vCntSum[i - 1]) % mod } for (i in 1..100000) { if (rCnt[m - 1][i] != 0L) { val l = i.toLong() * a val r = (i.toLong() * b).coerceAtMost(100000) if (l <= r) { ans = (ans + (mod + vCntSum[r.toInt()] - vCntSum[l.toInt() - 1]) * rCnt[m - 1][i]) % mod } } } builder.appendln(ans) print(builder.toString()) } fun readInputLine(): String { return readLine()!! }