factor::Int->[Int]->Int
factor n xs = let idxs = zip [1..] xs in red_sum [ ((i-1)-(n-i)) |(i,v)<-idxs]
            where red_sum [] = 0
                  red_sum (x:xs) = mod (x+(red_sum xs)) 1000000007

solver::Int -> Int ->[Int]->[Int]->Int
solver n m xs ys = mod ((factor n xs) * (factor m ys)) 1000000007

main::IO()
main=do
  nmc<-getLine
  let n:m:[]=map read (words nmc)
  x<-getLine
  let xs=(map read (words x))
  y<-getLine
  let ys=(map read (words y))
  print (solver n m  xs ys)
