import Data.Int
modNum = 1000000007
toInt64 :: Int -> Int64
toInt64 = (fromInteger :: Integer -> Int64) . toInteger

main = do
  nm <- map (read :: String -> Int64) . words <$> getLine
  inputX <- map (read :: String -> Int64) . words <$> getLine
  inputY <- map (read :: String -> Int64) . words <$> getLine
  putStrLn . show $ solve' inputX inputY

solve' :: [Int64] -> [Int64] -> Int64
solve' x y = let n = toInt64 $ (length x) - 1
                 m = toInt64 $ (length y) - 1
                 in if m > 2 then flip mod modNum $ solve x y + solve' x (tail . init $ y)
                             else solve x y

solve :: [Int64] -> [Int64] -> Int64
solve x y = let n = toInt64 $ (length x) - 1
                m = toInt64 $ (length y) - 1
                xx = (last x) - (head x)
                yy = (last y) - (head y)
                area = flip mod modNum $ (flip mod modNum $ n * m) * (flip mod modNum $ xx * yy)
                in if n > 2 then flip mod modNum $ area + solve (tail . init $ x) y
                            else area
