import collections
n = int(input())
node_idx = 0
nodes = {}
g = []
cnt = []

for i in range(n):
    a,b,c,d = map(int, input().split())
    if not (a,b) in nodes:
        nodes[(a,b)] = node_idx
        node_idx += 1
        g.append([])
        cnt.append(0)
    if not (c,d) in nodes:
        nodes[(c,d)] = node_idx
        node_idx += 1
        g.append([])
        cnt.append(0)
    g[nodes[(a,b)]].append(nodes[(c,d)])
    g[nodes[(c,d)]].append(nodes[(a,b)])
    cnt[nodes[(a,b)]] += 1
    cnt[nodes[(c,d)]] += 1

remove = True
size_g = len(g)
while remove:
    remove = False
    for i in range(node_idx):
        if cnt[i] == 1:
            cnt[i] -= 1
            cnt[g[i][0]] -= 1
            g[g[i][0]].remove(i)
            g[i] = []
            remove = True

for i in range(node_idx):
    if len(g[i])>2:
        print("NO")
        exit()
print("YES")