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 q = 0; q < Q; q++) { int n = in.nextInt(); 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(); } Arrays.sort(X); Arrays.sort(Y); int countX = 0; for (int i = 1; i < n; i++) { if (X[i - 1] != X[i]) { countX++; } } int countY = 0; for (int i = 1; i < n; i++) { if (Y[i - 1] != Y[i]) { countY++; } } if ((countX == 1 && countY != 0) || (countY == 1 && countX != 0) || n == 1 || n == 2) { System.out.println("YES"); } else { System.out.println("NO"); } } } }