# Enter your code here. Read input from STDIN. Print output to STDOUT def check(np,t): l00=(-1,-1) l01=(-1,-1) l11=(-1,-1) l10=(-1,-1) maxl=-1 maxr=-1 for i in sorted(t): if maxl==-1 and maxr==-1: maxl=i[0] maxr=i[1] continue if i[0]!=maxl and i[0]!=maxr and i[1]!=maxl and i[1]!=maxr: #print (maxl,maxr) #print (i[0],i[1]) return "NO" if i[0]==maxl or i[1]==maxr: maxl=max(maxl,i[0]) maxr=max(maxr,i[1]) return "YES" T=input() for i in range(T): np=input() t=[] for j in range(np): t.append(map(int,raw_input().strip().split())) print check(np,t)