open Printf
open Scanf

let id x = x

let solve a b m =
  let aa = Array.init a @@ fun _ -> scanf "%d " id in
  let ab = Array.init b @@ fun _ -> scanf "%d " id in
  let rec loop mn i =
    if i = 0 then mn
    else let (x, y, c) = scanf "%d %d %d " @@ fun x y c -> (x, y, c) in
         loop (min mn (aa.(x - 1) + ab.(y - 1) - c)) (i - 1) in
  loop (Array.fold_left min aa.(0) aa + Array.fold_left min aa.(0) aa) m

let () =
  scanf "%d %d %d " solve |> printf "%d\n"
