import Data.Array

--勘違いによって、台形関数が死んだ...TimeUp
daikei::Int -> Int -> Int
daikei n l = if l >= ((div n 2)+(mod n 2)) then if (mod n 2) == 1 then ((div n 2)+1)*((div n 2)+1)
                                                                  else (div n 2)*((div n 2)+1)
                                           else ((n-l)+1)*l

--n,mマス中(l,k)マスは、何回ダブるか、
doubling::Int->Int->(Int,Int) -> Int
doubling n m (l,k) = (daikei n l)*(daikei m k)

get_width::[Int]->Array Int Int
get_width xs = let n = (length xs)-1 in listArray (1,n) [b-a|(a,b)<-(zip xs (tail xs))]

--マスサイズｎと、それぞれの幅アレイから、ダブリを使って和を計算。
total::Int->Int ->(Array Int Int)->(Array Int Int)->Int
total n m xar yar = red_sum [red_prod [(xar!i),(yar!j),doubling n m (i,j)]|i<-[1..n],j<-[1..m]]

red_prod::[Int]->Int
red_prod [] = 1
red_prod (x:xs) = mod (x * (red_prod xs)) 1000000007

red_sum::[Int]->Int
red_sum [] = 0
red_sum (x:xs) = mod (x + (red_sum xs)) 1000000007

main::IO()
main=do
  nmc<-getLine
  let n:m:[]=map read (words nmc)
  x<-getLine
  let xar= get_width (map read (words x))
  y<-getLine
  let yar= get_width (map read (words y))
  print (total (n-1) (m-1) xar yar)