import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int q = in.nextInt(); for(int test = 0 ; test < q ; test++) { int n = in.nextInt(); int maxX = Integer.MIN_VALUE; int minX = Integer.MAX_VALUE; int maxY = Integer.MIN_VALUE; int minY = Integer.MAX_VALUE; int x[] = new int[n]; int y[] = new int[n]; for(int i = 0 ; i < n ; i++) { x[i] = in.nextInt(); y[i] = in.nextInt(); maxX = Math.max(maxX, x[i]); maxY = Math.max(maxY, y[i]); minX = Math.min(minX, x[i]); minY = Math.min(minY, y[i]); } boolean possible = true; for(int i = 0 ; i < n ; i++) { if((x[i] == minX ) || (x[i] == maxX ) || (y[i] == minY) || (y[i] == maxY)) { possible = true; } else { possible = false; break; } } if(!possible) { System.out.println("NO"); } else { System.out.println("YES"); } } } }