defmodule Main do def main do 1..(IO.read(:line) |> String.trim() |> String.to_integer()) |> Enum.map(fn _ -> IO.read(:line) |> String.trim() |> String.split() |> Enum.map(&String.to_integer/1) end) |> solve |> IO.puts() end def solve(x) do solve_rec(x, {{2, 8}, {3, 9}, {7, 9}}) end def solve_rec([], {a, b, c}) do cond do a == {5, 8} && b == {4, 8} && c == {6, 8} -> "YES" true -> "NO" end end def solve_rec([[x1, y1, x2, y2] | t], {a, b, c}) do solve_rec( t, case {x1, y1} do ^a -> {{x2, y2}, b, c} ^b -> {a, {x2, y2}, c} ^c -> {a, b, {x2, y2}} _ -> {a, b, c} end ) end end