# Enter your code here. Read input from STDIN. Print output to STDOUT q = int(raw_input().strip()) for i in xrange(q): n = int(raw_input().strip()) x_min = float("inf") y_min = float("inf") x_max = float("-inf") y_max = float("-inf") points = list() for i in xrange(n): x, y = raw_input().strip().split(' ') x, y = [int(x), int(y)] points.append((x, y)) if x < x_min: x_min = x if x > x_max: x_max = x if y < y_min: y_min = y if y > y_max: y_max = y res = 'YES' for x, y in points: if x != x_min and x != x_max and y != y_min and y != y_max: res = 'NO' break elif (((x == x_min or x == x_max) and (y < y_min or y > y_max)) or ((y == y_min or y == y_min) and (x < x_min or x > x_max))): res = 'NO' break print res