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 k = 0; k < q; k++){ int n = in.nextInt(); int[] x = new int[n]; int[] y = new int[n]; int minx = 100000; int maxx = -100000; int miny = 100000; int maxy = -100000; for(int i = 0; i < n; i++){ x[i] = in.nextInt(); y[i] = in.nextInt(); if(x[i] < minx)minx=x[i]; if(x[i] > maxx)maxx=x[i]; if(y[i] < miny)miny=y[i]; if(y[i] > maxy)maxy=y[i]; } int cond = 0; for(int i = 0; i < n; i++){ //if((x[i] != minx && x[i] != maxx) || (y[i] != miny && y[i] != maxy))cond = 1; //if(y[i] != miny && y[i] != maxy)cond=1; if(x[i] == minx || x[i] == maxx){ if(y[i] < miny || y[i] > maxy)cond=1; }else if(y[i] == miny || y[i] == maxy){ if(x[i] < minx || x[i] > maxx)cond=1; }else{ cond=1; } } if(cond != 0){ System.out.println("NO"); }else{ System.out.println("YES"); } } } }