import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int q = sc.nextInt(); for (int i = 0; i < q; i++) { int n = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; for (int j = 0; j < n; j++) { x[j] = sc.nextInt(); y[j] = sc.nextInt(); } int xmax = Integer.MIN_VALUE; int xmin = Integer.MAX_VALUE; for (int elem : x) { if (elem > xmax) {xmax = elem;} if (elem < xmin) {xmin = elem;} } int ymax = Integer.MIN_VALUE; int ymin = Integer.MAX_VALUE; for (int elem : y) { if (elem > ymax) {ymax = elem;} if (elem < ymin) {ymin = elem;} } boolean yes = true; for (int k = 0; k < n; k++) { if (x[k] != xmax && x[k] != xmin && y[k] != ymax && y[k] != ymin) { yes = false; break; } } System.out.println(yes ? "YES" : "NO"); } } }