import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { try(Scanner scan = new Scanner(System.in)) { int q = scan.nextInt(); while(q-- > 0) { int n = scan.nextInt(); int minx = Integer.MAX_VALUE; int maxx = Integer.MIN_VALUE; int miny = Integer.MAX_VALUE; int maxy = Integer.MIN_VALUE; int xMiny = Integer.MAX_VALUE; int xMaxy = Integer.MIN_VALUE; int yMinx = Integer.MAX_VALUE; int yMaxx = Integer.MIN_VALUE; int[][] points = new int[n][2]; while(n-- > 0) { int x = scan.nextInt(); int y = scan.nextInt(); points[n][0] = x; points[n][1] = y; if(x < minx) minx = x; if(x > maxx) maxx = x; if(y < miny) miny = y; if(y > maxy) maxy = y; } int len = points.length; boolean result = true; while(len-- > 0) { if((points[len][0] <= maxx && points[len][0] >= minx && (points[len][1] == miny || points[len][1] == maxy)) || (points[len][0] == maxx || points[len][0] == minx && (points[len][1] >= miny || points[len][1] <= maxy))) { } else { result = false; break; } } if(result) System.out.println("YES"); else System.out.println("NO"); } } } }