{-# LANGUAGE MultiParamTypeClasses,FlexibleContexts,FlexibleInstances,TypeSynonymInstances,BangPatterns,RankNTypes,TupleSections #-}
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Control.Arrow
import Debug.Trace
import Text.Printf

import Data.List
import Data.Int
import Data.Bits
import Data.Maybe
import Data.Monoid
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.Base
import Data.Function(on)
import Data.Tuple(swap)
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    (n,c) <- readIntPair
    as <- readInts
    bs <- readInts
    let xa :: UArray (Int,Int) Int64
        xa = listArray ((1,0),(400,400)) [ getInteger (x^a) | x <- [1..400 :: Modulo], a <- [0..400] ]
        ya :: UArray (Int,Int) Int64
        ya = listArray ((0,0),(length as-1,400)) [ sum [ (xa ! (x,e)) | x <- [a..b] ] `mod` modulo | (a,b) <- zip as bs, e <- [0..400 :: Int] ]
    let arr :: Int64
        arr = runST $ do
            dp <- newUArray ((0,0),(c,n)) (-1)
            let go v _ [] = if v == 0 then return 1 else return 0
                go v i (x:xs) = do
                    b <- readArray dp (v,i)
                    if b /= -1 then
                        Modulo <$> readArray dp (v,i)
                    else do
                        writeArray dp (v,i) 0
                        rep_ (v+1) $ \a -> do
                            r <- go (v - a) (i+1) xs
                            cur <- readArray dp (v,i)
                            writeArray dp (v,i) (getInteger (Modulo cur + Modulo (ya ! (i,a))* r))
                        Modulo <$> readArray dp (v,i)
            getInteger <$> go c 0 as
    if arr < 0 then
        print ((1::Int) `div` 0)
    else
        print arr




modulo :: Int64
modulo = 1000000007

newtype Modulo = Modulo { getInteger :: Int64 } deriving(Eq,Ord)
instance Num Modulo where
    Modulo a + Modulo b = Modulo ((a+b) `mod` modulo)
    Modulo a - Modulo b = Modulo ((a-b) `mod` modulo)
    Modulo a * Modulo b = Modulo ((a*b) `mod` modulo)
    abs (Modulo a) = Modulo (abs a)
    signum (Modulo a) = Modulo (signum a)
    fromInteger i = Modulo (fromInteger i)
instance Fractional Modulo where
    recip (Modulo !a) = Modulo (modInv a)
    fromRational = undefined

instance Enum Modulo where
    toEnum x = fromIntegral x
    fromEnum x = fromIntegral $ getInteger x

instance Show Modulo where
    show (Modulo i) = show i
 
modInv i = (modulo + x `mod` modulo) `mod` modulo
    where
    (x,y) = go i modulo
    go !a 0 = (1,0)
    go !a b = let (!y,!x) = go b (a `mod` b) in (x,y - a `div` b * x)


-- IO
readInt :: B.ByteString -> Int
readInt = fromJust . fmap fst . B.readInt
readInts :: IO [Int]
readInts = map readInt . B.words <$> B.getLine
readIntPair :: IO (Int,Int)
readIntPair = l2p . map readInt . take 2 . B.words <$> B.getLine
readAllInts :: IO [[Int]]
readAllInts = map (map readInt . B.words) . B.lines <$> B.getContents
readLns :: Read a => IO [a]
readLns = map read . words <$> getLine

-- Utilities
l2p :: [a] -> (a,a)
l2p (a:b:_) = (a,b)
l2p _ = error "l2p: the input list is too short"
p2l :: (a,a) -> [a]
p2l (a,b) = [a,b]
itof :: Int -> Double
itof = fromIntegral
inf :: Int
inf = maxBound `div` 2

-- Monad
stepM_ :: Monad m => a -> (a -> Bool) -> (a -> a) -> (a -> m ()) -> m ()
stepM_ i0 judge incr step = sub i0 where 
    sub i | judge i = step i >> sub (incr i) 
          | otherwise = return ()
rep_ :: Monad m => Int -> (Int -> m ()) -> m ()
rep_ n = stepM_ 0 (<n) (+1)
thru :: Monad m => (v -> m ()) -> v -> m v
thru m v = m v >> return v
memoize :: (Monad m) => (k -> m (Maybe v)) -> (k -> v -> m ()) -> k -> m v -> m v
memoize getter setter key action = do
    mv <- getter key
    case mv of
        Just v -> return v
        Nothing -> action >>= thru (setter key)

-- Array
newUArray :: (MArray (STUArray s) e (ST s),Ix i) => 
             (i,i) -> e -> ST s (STUArray s i e)
newUArray = newArray
newBArray :: (Ix i) => (i,i) -> e -> ST s (STArray s i e)
newBArray = newArray
defaultArray :: (IArray a e,Ix i) => e -> (i,i) -> [(i,e)] -> a i e
defaultArray = accumArray $ curry snd
fromEdges :: Ix i => (i,i) -> [(i,e)] -> Array i [e]
fromEdges = accumArray (flip (:)) []


Measured memory_bytes: 7932