q=int(input().strip()) for query in range(0,q): n=int(input().strip()) count=0 sum=0 for points in range(0,n): x,y=[int(arr_temp) for arr_temp in input().strip().split()] if(x==0 and y==0): count+=1 elif(x==0 and y!=0): if(sum==0): sum=y count+=1 else: if(sum==y): count+=1 elif(y==0 and x!=0): if(sum==0): sum=x count+=1 else: if(sum==x): count+=1 elif(x==y): if(sum==0): sum=x count+=1 else: if(sum==x): count+=1 if(count==n): print("YES") else: print("NO")