main = do
  [_,_] <- map read.words <$> getLine :: IO [Integer]
  xs <- map read.words <$> getLine :: IO [Integer]
  ys <- map read.words <$> getLine :: IO [Integer]
  print $ (`mod`1000000007) $ sum [(xr-xl)*(yt-yb)|xl<-init xs,xr<-tail xs,xr>xl,yb<-init ys,yt<-tail ys,yt>yb]
