import Data.Array
import qualified Data.ByteString.Char8 as C
import Data.List

main = C.interact $ put . sol . get

get = fmap (unfoldr (C.readInt . C.dropWhile (==' '))) . C.lines

put = C.pack . show

sol [[n,m],xs,ys] = f 1 n 1 m
  where
  x = listArray (1,n) $ fmap Modulo xs
  y = listArray (1,m) $ fmap Modulo ys
  f i j k l
    | j-i<=2 && l-k<=2  = g i j k l 
    | j-i<=2            = g i j k l+f i j (k+1) (l-1)
    | l-k<=2            = g i j k l+f (i+1) (j-1) k l
    | otherwise         = g i j k l+f i j (k+1) (l-1)+f (i+1) (j-1) k l-f (i+1) (j-1) (k+1) (l-1)
  g i j k l = (x!j-x!i)*(y!l-y!k)*Modulo (j-i)*Modulo(l-k)

p = 10^9+7 :: Int
newtype Modulo = Modulo { getInt :: Int } deriving (Eq, Ord)

instance Num Modulo where
  Modulo a + Modulo b = Modulo ((a + b) `mod` p)
  Modulo a - Modulo b = Modulo ((a - b) `mod` p)
  Modulo a * Modulo b = Modulo ((a * b) `mod` p)
  abs = undefined
  negate = undefined
  signum = undefined
  fromInteger i = Modulo (fromIntegral i `mod` p)

instance Show Modulo where
  show (Modulo i) = show i