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 sc = new Scanner(System.in); int q = sc.nextInt(); while(q>0) { int n = sc.nextInt(); int a[] = new int[n]; int b[] = new int[n]; for(int i = 0; i < n; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); } int flag1 = 0; for(int i = 0; i < n; i++) { flag1 = 0; for(int j = 0; j < n;j++) { if(a[i] == a[j] && i != j) { for(int k = i; k < n; k++) { for(int l = 0; l < n;l++) { if(b[k] == b[l] && k != l) { flag1 = 1; } } } } } if(flag1 == 0) { break; } } if(flag1 == 0) { System.out.println("NO"); }else{ System.out.println("YES"); } q--; } } }