import java.util.Scanner; import java.util.TreeSet; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for (int t = 0; t < T; t++) { TreeSet x = new TreeSet<>(); TreeSet y = new TreeSet<>(); int n = sc.nextInt(); int[][] pts = new int[n][2]; for (int i = 0; i < n; i++) { int pX = sc.nextInt(); int pY = sc.nextInt(); pts[i] = new int[] {pX, pY}; x.add(pX); y.add(pY); } boolean OK = true; for (int[] pt : pts) { if (pt[0] != x.first() && pt[0] != x.last() && pt[1] != y.first() && pt[1] != y.last()) { OK = false; break; } } System.out.println(OK ? "YES" : "NO"); } } }