let () = Scanf.scanf "%d %d %d\n" @@ fun a b m ->
  let as_ = Array.init a @@ fun _ -> Scanf.scanf "%d%c" @@ fun a _ -> a in
  let bs = Array.init b @@ fun _ -> Scanf.scanf "%d%c" @@ fun b _ -> b in
  let xycs = Array.init m @@ fun _ -> Scanf.scanf "%d %d %d\n" @@ fun x y c -> x, y, c in
  Printf.printf "%d\n" @@
  Array.fold_right (fun (x, y, c) -> min @@ as_.(x - 1) + bs.(y - 1) - c) xycs @@
  Array.fold_left min max_int as_ + Array.fold_left min max_int bs