let iota ?(start=0) ?(step=1) cnt = let rec doit i acc = if i <= 0 then acc else doit (i - 1) (start + step*(i - 1) :: acc) in doit cnt [] let other l = iota 10 |> List.filter (fun e -> not (List.mem e l)) let () = let t = Array.make 10 true in let n = Scanf.scanf "%d " (fun i -> i) in for i = 0 to n - 1 do let a, b, c, d, r = Scanf.scanf "%d %d %d %d %s " (fun a b c d r -> a, b, c, d, r) in let l = [a; b; c; d] in List.iter (fun e -> t.(e) <- false) (if r = "NO" then l else other l) done; let rec doit i = if t.(i) then i else doit (i + 1) in doit 0 |> Printf.printf "%d\n"