local n = io.read("*n") local t = {} for i = 1, n do local a, b = io.read("*n", "*n") local c, d = io.read("*n", "*n") local i1 = (a - 1) * 9 + b local i2 = (c - 1) * 9 + d local found = false for k, v in pairs(t) do if v == i1 then found = true t[k] = i2 break end end if not found then t[i1] = i2 end end local r = t[17] == 44 and t[27] == 35 and t[63] == 53 print(r and "YES" or "NO")