q = int(input()) x, y = set(), set() for i in range(q): n = int(input()) for j in range(n): points = input().split() x.add(points[0]) y.add(points[1]) if len(x) == 2 and len(y) == 2: print("YES") else: print("NO") x.clear() y.clear()