import java.io.*; import java.util.*; public class Solution { private static boolean rect(int[] x, int[] y, int n) { if (n < 3) { return true; } int minX = x[0]; int maxX = x[0]; int minY = y[0]; int maxY = y[0]; for (int i = 1; i < n; i++) { minX = Math.min(minX, x[i]); minY = Math.min(minY, y[i]); maxX = Math.max(maxX, x[i]); maxY = Math.max(maxY, y[i]); } for (int i = 0; i < n; i++) { boolean b = false; if ((x[i] == minX || x[i] == maxX) && (y[i] >= minY && y[i] <= maxY)) { b = true; } if ((y[i] == minY || y[i] == maxY) && (x[i] >= minX && x[i] <= maxX)) { b = true; } if (!b) { return false; } } return true; } 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 t = sc.nextInt(); while(t-- > 0) { int n = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; for (int i = 0; i < n; i++) { x[i] = sc.nextInt(); y[i] = sc.nextInt(); } System.out.println(rect(x, y, n) ? "YES" : "NO"); } } }