let solve rc_lst = let rec solve' lst (result: Set list) = //eprintfn "%A" result match lst with | [] -> true | x::xs -> let r0, c0, r1, c1 = x let result = match result with | [] -> [set[(r0, c0)]; set[(r1, c1)]] | _ -> result |> List.map (fun s -> match (Set.contains (r0, c0) s), (Set.contains (r1, c1) s) with | true, true -> [] | false, true -> [(Set.add (r0, c0) s)] | true, false -> [(Set.add (r1, c1) s)] | false, false -> [(Set.add (r0, c0) s); (Set.add (r1, c1) s)]) |> List.concat if result = [] then false else solve' xs result solve' rc_lst [] let () = let n = stdin.ReadLine() |> int let rc_lst = seq { for _ in 1..n do let r0, c0, r1, c1 = stdin.ReadLine() |> fun s -> s.Split() |> Array.map int |> fun arr -> arr.[0], arr.[1], arr.[2], arr.[3] yield (r0, c0, r1, c1) } |> List.ofSeq solve rc_lst |> function | true -> "YES" | false -> "NO" |> printfn "%s"