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) { Scanner scan = new Scanner(System.in); int q = scan.nextInt(); for(int qi = 0; qi < q; qi++) { int n = scan.nextInt(); int[] x = new int[n]; int[] y = new int[n]; for(int i = 0; i < n; i++) { x[i] = scan.nextInt(); y[i] = scan.nextInt(); } String answer = "YES"; Integer maxX = null; Integer minX = null; Integer maxY = null; Integer minY = null; for(int i = 0; i < n; i++) { if(maxX == null) { maxX = minX = x[i]; maxY = minY = y[i]; } if(x[i] > maxX) { maxX = x[i]; } else if (x[i] < minX) { minX = x[i]; } if(y[i] > maxY) { maxY = y[i]; } else if (y[i] < minY) { minY = y[i]; } } for(int i = 0; i < n; i++) { if(x[i] != maxX && x[i] != minX && y[i] != maxY && y[i] != minY) { answer = "NO"; break; } } System.out.println(answer); } } }