let c = 1_000_000_007
let n, m = Scanf.scanf "%d %d" (fun n m -> n, m)

let f = fun _ -> Scanf.scanf " %d" (fun i -> i)
let x = Array.init n f
let y = Array.init m f

let f n x =
  let rec g i t s =
    if i = -1 then s
    else
      let t = (t + x.(i + 1)) mod c in
      g (i - 1) t ((s + t - (n - 1 - i) * x.(i)) mod c)
  in g (n - 2) 0 0

let () =
  let sx = f n x in
  let sy = f m y in
  Printf.printf "%d\n" (sx * sy mod c)
