import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); for(int i = 0; i < a; i++){ int b = scan.nextInt(); int[][] c = new int[b][2]; int xmin = 10000; int ymin = 10000; int xmax = -10000; int ymax = -10000; for(int j = 0; j < b; j++){ c[j][0] = scan.nextInt(); xmin = Math.min(xmin, c[j][0]); xmax = Math.max(xmax, c[j][0]); c[j][1] = scan.nextInt(); ymin = Math.min(ymin, c[j][1]); ymax = Math.max(ymax, c[j][1]); } String check = "YES"; for(int[] d : c){ if(d[0] != xmin && d[0] != xmax && d[1] != ymin && d[1] != ymax){ check = "NO"; } } System.out.println(check); } } }