import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int q = scan.nextInt(); for (int i = 0;i < q;i++) { int points = scan.nextInt(); int[] pointsX = new int[points]; int[] pointsY = new int[points]; int maxX = -100000; int maxY = -100000; int minX = 100000; int minY = 100000; for (int j = 0;j < points;j++) { pointsX[j] = scan.nextInt(); pointsY[j] = scan.nextInt(); if(pointsX[j] > maxX) maxX = pointsX[j]; if(pointsX[j] < minX) minX = pointsX[j]; if(pointsY[j] > maxY) maxY = pointsY[j]; if(pointsY[j] < minY) minY = pointsY[j]; } //System.out.println("MaxX: " + maxX + " minX: " + minX + " maxY: " + maxY + " minY: " + minY); boolean allOn = true; for(int j = 0;j < points;j++) { if(!(pointsX[j] == maxX || pointsX[j] == minX || pointsY[j] == maxY || pointsY[j] == minY)) { allOn = false; } } System.out.println(allOn ? "YES" : "NO"); } } }