fun main(args:Array<String>?): Unit {
    val mod = 1_000_000_007L
    val (n, l) = readLine()!!.trim().split(' ').map(String::toInt)
    val initialPosition = readLine()!!.trim().split(' ').map(String::toInt) + l
    val jump = readLine()!!.trim().split(' ').map(String::toInt) + 0
    val memo = Array(n + 1){LongArray(0)}//memo[i][x] i番目のウサギがx回右に飛んだ時にありうる右側のパターン. memo[n]は番兵
    memo[n] = LongArray(1){1L}
    for (i in n - 1 downTo 0) {
        var next = memo[i + 1].lastIndex
        val mostRight = next * jump[i + 1] + initialPosition[i + 1]
        memo[i] = if (jump[i] != 0) LongArray((mostRight - initialPosition[i] - 1) / jump[i] + 1){0L} else LongArray(1){0L}
        for (j in memo[i].lastIndex downTo 0) {
            if (j != memo[i].lastIndex) memo[i][j] = memo[i][j + 1]
            while(next >= 0 && j * jump[i] + initialPosition[i] < next * jump[i + 1] + initialPosition[i + 1]){
                memo[i][j] += memo[i + 1][next--]
            }
            memo[i][j] %= mod
        }
    }
    println(memo[0].sum() % mod)
}
