let n = 1000000007
let ( *^ ) x y = x * y mod n

let () =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m) in
  let xs = Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x)) in
  let ys = Array.init m (fun _ -> Scanf.scanf "%d " (fun y -> y)) in
  Printf.printf "%d\n" @@ (xs.(n - 1) - xs.(0)) *^ (ys.(m - 1) - ys.(0)) *^ (n - 1) *^ (m - 1)