def load(q): r = [] for i in range(q): x,y = map(int, input().split()) r.append( (x,y) ) return r def solve(pairs): right, top = -100000,-100000 left, bottom = 100000,100000 for x,y in pairs: right = max(right, x) top = max(top, y) left = min(left, x) bottom = min(bottom, y) for x,y in pairs: if (left < x < right) and (y!=top and y!=bottom): return False if (bottom < y < top) and (x!=left and x!=right): return False return True for _ in range(int(input())): print("YES" if solve(load(int(input()))) else "NO")