# Enter your code here. Read input from STDIN. Print output to STDOUT q = int(raw_input()) while q: n = int(raw_input()) b = 'YES' xg,yg = 0,0 while n and (b == 'YES'): x,y = map(int,raw_input().split(' ')) if max(x,y) < max(xg,yg): b = 'NO' xg,yg = max(x,y),max(x,y) n -= 1 print b q -= 1