# Enter your code here. Read input from STDIN. Print output to STDOUT Q = input() for q in range(Q): n = input() x = [] y = [] for i in range(n): xx, yy = map(int, raw_input().split()) x.append(xx) y.append(yy) mx = min(x) my = min(y) Mx = max(x) My = max(y) sirve = True for i in range(n): if x[i] not in (mx, Mx) and y[i] not in (my, My): sirve = False if sirve: print "YES" else: print "NO"