fun main(args: Array<String>) {
  val MOD = (1e9 + 7).toLong()
  val (n, c) = readLine()!!.split(" ").map { it.toInt() }
  val a = readLine()!!.split(" ").map { it.toInt() }
  val b = readLine()!!.split(" ").map { it.toInt() }
  var h = Array(c + 1) { LongArray(401) { 1L } }
  for (p in 1..c) {
    for (x in 1..400) {
      h[p][x] = h[p - 1][x] * x
      h[p][x] %= MOD
    }
  }
  var g = Array(n) { LongArray(c + 1) { 0L } }
  for (i in 0 until n) {
    for (p in 0..c) {
      for (x in a[i]..b[i]) {
        g[i][p] += h[p][x]
        g[i][p] %= MOD
      }
    }
  }
  var dp = Array(n + 1) { LongArray(c + 1) { 0L } }
  dp[0][0] = 1L
  for (i in 0 until n) {
    for (j in 0..c) {
      for (p in 0..j) {
        dp[i + 1][j] += dp[i][j - p] * g[i][p]
        dp[i + 1][j] %= MOD
      }
    }
  }
  println(dp[n][c])
}
