import java.util.Scanner; public class RectanglePoints { public static void main(String[] args) { Scanner s = new Scanner(System.in); int q = s.nextInt(); int x1=0,y1=0,x2=0,y2=0,flagx = 0,flagy = 0; for (int i = 0; i < q; i++) { int n = s.nextInt(); int flag = 0; for (int j = 0; j < n; j++) { int a = s.nextInt(); int b = s.nextInt(); if(j==0){ x1 = a; y1 = b; } else { if(flagx==0 && flagy==0){ if(x1!=a){ x2 = a; flagx = 1; } if(y1!=b){ y2 = b; flagy = 1; } continue; } if(flagx==0 && flagy==1){ if(x1!=a){ x2 = a; flagx = 1; if(!(b>=Math.min(y1, y2) && b<=Math.max(y1, y2))){ flag=1; break; } } continue; } if(flagx==1 && flagy==0){ if(y1!=b){ y2 = b; flagy = 1; if(!(a>=Math.min(x1, x2) && a<=Math.max(x1, x2))){ flag=1; break; } } continue; } if(flagx==1 && flagy==1){ if(!((a==x1 || a==x2)&&(b>=Math.min(y1, y2) && b<=Math.max(y1, y2))) && !((b==y1 || b==y2)&&(a>=Math.min(x1, x2) && a<=Math.max(x1, x2)))){ flag = 1; break; } } } } if(flag==0)System.out.println("YES"); else { System.out.println("NO"); } } } }