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 in = new Scanner(System.in); int testCases = Integer.parseInt(in.nextLine()); while(testCases > 0){ int dots = in.nextInt(); Map x = new HashMap<>(); Map y = new HashMap<>(); for (int i = 0; i < dots; i++) { int nextX = in.nextInt(); int nextY = in.nextInt(); if (!x.containsKey(nextX)) { if (!y.containsKey(nextY)) { // System.out.println("putting x = " + nextX + " in"); x.put(nextX, 0); //System.out.println("putting y = " + nextY + " in"); y.put(nextY, 0); } } if (!y.containsKey(nextY)) { if (!x.containsKey(nextX)) { //System.out.println("putting x = " + nextX + " in"); x.put(nextX, 0); //System.out.println("putting y = " + nextY + " in"); y.put(nextY, 0); } } } if (x.size() <= 2 && y.size() <= 2) { System.out.println("YES"); } else { System.out.println("NO"); } testCases--; } } }