import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

const val MOD = 1000000007L

fun main() {
    val pow = Array(401) { LongArray(401) }
    for (k in 0..400) {
        pow[k][0] = 1L
        for (e in 1..400) {
            pow[k][e] = (pow[k][e - 1] * k.toLong()) % MOD
        }
    }
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val (n, c) = jin.readLine().split(" ").map { it.toInt() }
    val dp = Array(n + 1) { LongArray(c + 1) }
    dp[0][0] = 1L
    val tokenizerA = StringTokenizer(jin.readLine())
    val tokenizerB = StringTokenizer(jin.readLine())
    for (j in 1..n) {
        val a = tokenizerA.nextToken().toLong()
        val b = tokenizerB.nextToken().toLong()
        for (e in 0..c) {
            var factor = 0L
            for (k in a..b) {
                factor += pow[k.toInt()][e]
            }
            factor %= MOD
            for (j2 in e..c) {
                dp[j][j2] += factor * dp[j - 1][j2 - e]
                dp[j][j2] %= MOD
            }
        }
    }
    println(dp[n][c])
}