import Control.Applicative
 
main = do
  [n, m] <- map read . words <$> getLine
  xs <- map read . words <$> getLine
  ys <- map read . words <$> getLine
  putStr . show . g m n $ (f xs) * (f ys)
 
f zs = (maximum zs) - (minimum zs)
 
g n m x = mod (x * (n+m-3)) 1000000007