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 q = in.nextInt(); for (int i = 0; i < q; i++) { int n = in.nextInt(); HashSet xvals = new HashSet<>(); HashSet yvals = new HashSet<>(); boolean works = true; for (int j = 0; j < n; j++) { int x = in.nextInt(); int y = in.nextInt(); if (!xvals.contains(x) && xvals.size() == 2) { works = false; break; } else if (!xvals.contains(x)) { xvals.add(x); } if (!yvals.contains(y) && yvals.size() == 2) { works = false; break; } else if (!yvals.contains(y)) { yvals.add(y); } } if (works) { System.out.println("YES"); } else { System.out.println("NO"); } } } }