# Enter your code here. Read input from STDIN. Print output to STDOUT import operator for _ in range(input()): n = input() arr = [] for i in range(n): x, y = map(int, raw_input().strip().split()) arr.append((x, y)) arr.sort(key = operator.itemgetter(0, 1)) x1, y1 = arr[0] x4 = arr[-1][0] y4 = max(arr, key = operator.itemgetter(1))[1] ##x4, y4 = arr[-1] ##x2, y2 = x4, y1 ##x3, y3 = x1, y4 """ print " arr = ", arr print " x1, y1 = ", x1, y1 print " x4, y4 = ", x4, y4 print "----------------" """ for i, j in arr: """ print " i = ", i print " j = ", j print "----------------" """ f = 0 if i == x1 or i == x4 or j == y1 or j == y4: if j == y1 or j == y4 or i == x1 or i == x4: continue else: f = 1 break else: f = 1 break break print "YES" if f == 0 else "NO"