import java.util.Scanner; import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int q = sc.nextInt(); while(q-->0){ int n = sc.nextInt(); HashMap map = new HashMap(); int xmin=Integer.MAX_VALUE; int xmax=Integer.MIN_VALUE; int ymin=Integer.MAX_VALUE; int ymax=Integer.MIN_VALUE; for(int i=0; ix) xmin = x; if(xmax<=x) xmax=x; if(ymin>y) ymin=y; if(ymax<=y) ymax=y; } Iterator entries = map.entrySet().iterator(); int flag=0; while (entries.hasNext()) { Map.Entry entry = (Map.Entry) entries.next(); Integer x = (Integer)entry.getKey(); Integer y = (Integer)entry.getValue(); if(x==xmin||x==xmax||y==ymin||y==ymax) continue; else flag=1; break; } if(flag==0)System.out.println("YES"); else System.out.println("NO"); } } }