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] = sum [f i k | i <- [1..n-1], k <- [1..m-1]]
  where
  x = listArray (1,n) $ fmap Modulo xs
  y = listArray (1,m) $ fmap Modulo ys
  n' = Modulo n
  m' = Modulo m
  f i k = (x!(i+1)-x!i)*(y!(k+1)-y!k)*i'*(n'-i')*k'*(m'-k')
    where
    i' = Modulo i
    k' = Modulo 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