modNum = 1000000007

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

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

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