let () = Scanf.scanf "%d %d %d\n" @@ fun n m x ->
  let icass = List.init n @@ fun i ->
    Scanf.scanf "%d " @@ fun c ->
      (i, c, List.init m @@ fun _ -> Scanf.scanf "%d " Fun.id) in
  let ans =
    List.fold_left min max_int @@
    List.init (1 lsl n) @@ fun bits ->
      let skill = Array.make m 0 in
      let cost =
        List.fold_left (fun cost (i, c, as_) ->
          if bits land (1 lsl i) = 0
          then cost
          else begin
            List.iteri (fun j a ->
              skill.(j) <- a + skill.(j)) as_;
            c + cost
          end) 0 icass in
      if
        List.for_all (( <= ) x) @@
        Array.to_list skill
      then cost
      else max_int in
  Printf.printf "%d\n" @@
  if ans = max_int then -1 else ans

