def scc(N, G): order = [] used = [False]*N group = [None]*N RG = [[] for _ in range(N)] for i in range(N): for j in G[i]: RG[j].append(i) def dfs(pos): stack = [(1, pos), (0, pos)] while stack: t, pos = stack.pop() if t == 0: if used[pos]: stack.pop() continue used[pos] = True for npos in G[pos]: if not used[npos]: stack.append((1, npos)) stack.append((0, npos)) else: order.append(pos) def rdfs(pos, col): stack = [pos] group[pos] = col used[pos] = True while stack: pos = stack.pop() for npos in RG[pos]: if not used[npos]: used[npos] = True group[npos] = col stack.append(npos) for i in range(N): if not used[i]: dfs(i) used = [False]*N label = 0 for s in reversed(order): if not used[s]: rdfs(s, label) label += 1 return label, group class Two_SAT: def __init__(self, n): self.n = n self.G = [[] for _ in range(2 * n)] # a V B # pos_i = True -> a = i # pos_i = False -> a = ¬i def add_edge(self, i, pos_i, j, pos_j): i0 = i i1 = i + self.n if not pos_i: i0, i1 = i1, i0 j0 = j j1 = j + self.n if not pos_j: j0, j1 = j1, j0 self.G[i1].append(j0) self.G[j1].append(i0) def const(self): _, self.group = scc(2 * self.n, self.G) def check(self): for i in range(self.n): if self.group[i] == self.group[i + self.n]: return False return True def assign(self): ret = [False] * self.n for i in range(self.n): if self.group[i] > self.group[i + self.n]: ret[i] = True return ret n = int(input()) RC = [list(map(int, input().split())) for _ in range(n)] TS = Two_SAT(n) for i in range(n): r0, c0, r1, c1 = RC[i] for j in range(i + 1, n): r2, c2, r3, c3 = RC[j] for ii, p0 in enumerate([(r0, c0), (r1, c1)]): for jj, p1 in enumerate([(r2, c2), (r3, c3)]): if p0 == p1: TS.add_edge(i, ii, j, jj) TS.const() if TS.check(): print("YES") else: print("NO")