# Enter your code here. Read input from STDIN. Print output to STDOUT from fractions import gcd aa=gcd(10,20) a = pow(10,20,10) def abc(): aa=pow(10,20,20) return aa auth = "biggydbs" ct = 0 author = "akkd" n=input() while n>0: n-=1 t = input() l=[] ct = [] ctt = [] nn=t while t>0: t-=1 a,b = map(int,raw_input().split()) l.append([a,b]) ct.append(a) ctt.append(b) x_max = max(ct) x_min = min(ct) y_max = max(ctt) y_min = min(ctt) flag = 0 for i in range(nn): if l[i][0] != x_max and l[i][0] != x_min and l[i][1] != y_max and l[i][1] != y_min: flag = 1 if flag == 1: print "NO" else: print "YES"