import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s
main :: IO ()
main = do
    -- スペース区切り整数の入力
    [n, m] <- map strToInt . words <$> getLine
    -- スペース区切り整数の入力
    xaxis <- map strToInteger . words <$> getLine
    yaxis <- map strToInteger . words <$> getLine
    let x = maximum xaxis - minimum xaxis
        y = maximum yaxis - minimum yaxis
        m' = 10^9 + 7
    -- 出力
    putStrLn . show $ ((x * y) * (2 ^ ((fromIntegral (n + m - 4))))) `mod` m'
