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) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int q = sc.nextInt(); for(int i = 0 ; i < q ; i++){ int n = sc.nextInt(); int point[][] = new int[n][2]; for(int j = 0 ; j < n ; j++){ point[j][0] = sc.nextInt(); point[j][1] = sc.nextInt(); } int x1 = point[0][0] , y1 = point[0][1],k=1; int x2 = 0 , y2 = 0 ; for(int l = 0 ; l < n ; l++){ if(point[l][0]!=x1){ x2 = point[l][0]; y2 = point[l][1]; break; } } for( ; k < n ; k++){ if(!(point[k][0] == x1 || point[k][1] == y1 || point[k][0] == x2 || point[k][1] == y2)){ System.out.println("NO"); break; } } if(k==n){ System.out.println("YES"); } } } }