import java.io.*; import java.util.*; 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 in = new Scanner(System.in) ; int q = in.nextInt() ; for( int i = 0 ; i < q ; i++ ){ int n = in.nextInt() ; boolean flag = true ; int x , y ; x = y = 0 ; int[][] pts = new int[n][2] ; int[] xA = new int[2] ; int[] yA = new int[2] ; for( int j = 0 ; j < n ; j++ ){ pts[j][0] = in.nextInt() ; pts[j][1] = in.nextInt() ; } for( int j = 0 ; j < n ; j++ ){ if( x == 0 ){ xA[0] = pts[j][0] ; x++ ; } else if( x == 1 ){ if( xA[0] != pts[j][0] ){ xA[1] = pts[j][0] ; x++ ; } } else if( x == 2 ){ if( xA[0] != pts[j][0] && xA[1] != pts[j][0] ) flag = false ; break ; } if( y == 0 ){ yA[0] = pts[j][1] ; y++ ; } else if( y == 1 ){ if( yA[0] != pts[j][1] ){ yA[1] = pts[j][1] ; y++ ; } } else if( y == 2 ){ if( yA[0] != pts[j][1] && yA[1] != pts[j][1] ){ flag = false ; break ; } } } if( flag ) System.out.println("YES") ; else System.out.println("NO") ; } } }