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(); for(int t = 0;t < q;t++){ int n = sc.nextInt(); int i,j,k; int x[] = new int[n]; int y[] = new int[n]; int xx = -100000, yy = -100000, xxx = 100000, yyy = 100000; for(i = 0;i < n;i++){ x[i] = sc.nextInt(); y[i] = sc.nextInt(); if(x[i] > xx){ xx = x[i]; } if(x[i] < xxx){ xxx = x[i]; } if(y[i] < yyy){ yyy = y[i]; } if(y[i] > yy){ yy = y[i]; } } int flag = 0; for(i = 0;i < n;i++){ if((x[i] == xx || x[i] == xxx) || (y[i] == yy || y[i] == yyy)){ } else{ flag = 1; } } if(flag == 1){ System.out.println("NO"); } else{ System.out.println("YES"); } } } }