import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Solution { /** * @param args */ public static void main(String[] args) { Scanner s = new Scanner(System.in); int q = s.nextInt(); while(q > 0){ q--; int n = s.nextInt(); int minX = Integer.MAX_VALUE; int maxX = Integer.MIN_VALUE; int minY = Integer.MAX_VALUE; int maxY = Integer.MIN_VALUE; boolean output = true; boolean edgeX = true; boolean edgeY = true; boolean present = true; List X = new ArrayList<>(); List Y = new ArrayList<>(); for(int i = 0; i< n;i++){ int x = s.nextInt(); int y = s.nextInt(); X.add(x); Y.add(y); if(x < minX){ minX = x; } if(x > maxX){ maxX = x; } if(y < minY){ minY = y; } if(y > maxY){ maxY = y; } } for(int i = 0; i< n; i++){ int x = X.get(i); int y = Y.get(i); edgeX = false; edgeY = false; present = false; if(x == minX || x ==maxX) edgeX = true; if(y == minY || y ==maxY) edgeY = true; if(edgeX || edgeY) present = true; if(!present){ output = false; break; } } if(output){ System.out.println("YES"); } else{ System.out.println("NO"); } } } }