# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(raw_input().strip()) for _ in xrange(n): q = int(raw_input().strip()) pairs = [map(int, raw_input().strip().split(" ")) for p in xrange(q)] is_true = True m_x = None m_y = None for p in pairs: x,y = p if x!=0 and not m_x: m_x = [0, x] if y!=0 and not m_y: m_y = [0, y] if m_x and x not in m_x: print "NO" is_true = False break if m_y and y not in m_y: print "NO" is_true = False break if is_true: print "YES"