import java.io.*; import java.util.*; public class Solution { public String query(List points, int pointNum){ Collections.sort(points, (a, b) ->(a[0] - b[0])); int minX = points.get(0)[0]; int maxX = points.get(pointNum - 1)[0]; Collections.sort(points, (a, b) -> (a[1] - b[1])); int minY = points.get(0)[1]; int maxY = points.get(pointNum - 1)[1]; for (int[] point : points){ boolean ok = false; if (point[0] == minX || point[0] == maxX){ ok = true; } if (point[1] == minY || point[1] == maxY){ ok = true; } if (!ok){ return "NO"; } } return "YES"; } public static void main(String[] args) { Solution soln = new Solution(); Scanner in = new Scanner(System.in); int queryNum = Integer.parseInt(in.nextLine()); for (int i = 0 ; i < queryNum; i++){ int pointNum = Integer.parseInt(in.nextLine()); List points = new ArrayList<>(); for (int j = 0 ; j < pointNum; j++){ String[] input = in.nextLine().split("\\s+"); points.add(new int[]{Integer.parseInt(input[0]), Integer.parseInt(input[1])}); } System.out.println(soln.query(points, pointNum)); } } }