nq = int(input().strip()) for q in range(nq): np = int(input().strip()) p = [tuple(int(x) for x in input().strip().split()) for i in range(np)] x0,x1 = min(x for x,y in p), max(x for x,y in p) y0,y1 = min(y for x,y in p), max(y for x,y in p) result = "YES" for x,y in p: if x == x0 or x == x1 or y == y0 or y== y1: continue else: result = "NO" break print(result)