# Enter your code here. Read input from STDIN. Print output to STDOUT q = int(raw_input().strip()) for _ in xrange(q): n = int(raw_input().strip()) points = [] for _ in xrange(n): x, y = map(int, raw_input().strip().split(' ')) points.append((x, y)) y_points = map(lambda (x, y) : y, points) top_line = max(y_points) bottom_line = min(y_points) x_points = map(lambda (x, y) : x, points) left_line = min(x_points) right_line = max(x_points) printed = False for x, y in points: if x != left_line and x != right_line and y != top_line and y != bottom_line: print('NO') printed = True break if not printed: print('YES')