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 reader = new Scanner(System.in); int q = reader.nextInt(); int n; for(int i = 0; i < q; i++){ n = reader.nextInt(); ArrayList sides = new ArrayList(); HashMap commonSides = new HashMap(); for(int x = 0; x < n; x++){ int sideX = reader.nextInt(); int sideY = reader.nextInt(); sides.add(new Side(sideX, sideY)); } if(checkSides(sides)){ System.out.println("YES"); }else{ System.out.println("NO"); } //for(Side side: sides){ // System.out.println(side.getX()+" "+side.getY()); //} } } static boolean checkSides(ArrayList sides){ int maxX = Integer.MIN_VALUE; int maxY = Integer.MIN_VALUE; int minX = Integer.MAX_VALUE; int minY = Integer.MAX_VALUE; for(Side side: sides){ if(side.getX() > maxX) maxX = side.getX(); if(side.getX() < minX) minX = side.getX(); if(side.getY() > maxY) maxY = side.getY(); if(side.getY() < minY) minY = side.getY(); } //there shouldn't be anything on a point that is not maxx, minx, maxy or miny for(Side side: sides){ if(side.getX() != maxX && side.getX() != minX && side.getY() != maxY && side.getY() != minY){ return false; } } return true; } } class Side{ private int x; private int y; public Side(int x, int y){ this.x = x; this.y = y; } public int getX(){ return x; } public int getY(){ return y; } }