program children_and_candies
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, c, a(400) = 0, b(400) = 0, i, j, k
  integer(8) :: p(0:400,0:400) = 0_8, m, dp(400,0:400) = 0_8
  read(*,*) n, c
  read(*,*) a(1:n)
  read(*,*) b(1:n)
  do i = 0, 400
    m = 0_8
    do j = 0, 400
      m = mod(m+pow(int(j,8),i),md)
      p(i,j) = m
    end do
  end do
  do i = 0, c
    dp(1,i) = mod(md+p(i,b(1))-p(i,a(1)-1),md)
  end do
  do i = 2, n
    do j = 0, c
      do k = 0, j
        dp(i,j) = mod(dp(i,j)+mod(dp(i-1,j-k)*(md+p(k,b(i))-p(k,a(i)-1)),md),md)
      end do
    end do
  end do
  write(*,'(i0)') dp(n,c)
  stop
contains
  recursive function pow(a,b) result(r)
    implicit none
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer(8) :: r
    r = 1_8
    if (b.eq.0) return
    if (mod(b,2).eq.0) then
      r = pow(a,b/2)
      r = mod(r*r,md)
      return
    end if
    r = mod(a*pow(a,b-1),md)
    return
  end function pow
end program children_and_candies