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] = f n xs*f m ys `mod` p

f n = fst . foldl' (\(a,i) x -> (a + x*(2*i-n-1) `mod` p,i+1)) (0,1)

p = 10^9+7 ::Int