import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int numQueries = scanner.nextInt(); for(int thisQuery = 0; thisQuery < numQueries; thisQuery++){ int numPoints = scanner.nextInt(); int[] X = new int[numPoints]; int[] Y = new int[numPoints]; for(int thisPoint = 0; thisPoint < numPoints; thisPoint++){ X[thisPoint] = scanner.nextInt(); Y[thisPoint] = scanner.nextInt(); } Set setx = new HashSet(); Set sety = new HashSet(); for(int i = 0; i < X.length; i++){ setx.add(X[i]); sety.add(Y[i]); } if(setx.size() > 2 || sety.size() > 2){ System.out.println("NO"); } else{ System.out.println("YES"); } } } }