q = int(input().strip()) # num queries for x in range(q): numPoints = int(input().strip()) result = 1 # assume pass x_set = set() y_set = set() for y in range(numPoints): xx, yy = [int(vv) for vv in input().strip().split()] x_set.add(xx) y_set.add(yy) if len(x_set) > 2 and len(y_set) > 2: result = 0 # fail - inner point if len(x_set) == 1 or len(y_set) == 1: result = 0 # fail - degenerate if result: print("YES") else: print("NO")