import java.util.*; public class Rect { private Point[] pts; private int xmax; private int xmin; private int ymax; private int ymin; public Rect(Point[] pts) { this.pts = pts; xmax = Integer.MIN_VALUE; ymax = Integer.MIN_VALUE; xmin = Integer.MAX_VALUE; ymin = Integer.MAX_VALUE; for (int i = 0; i < pts.length; i++) { xmin = Math.min(xmin, pts[i].x()); xmax = Math.max(xmax, pts[i].x()); ymin = Math.min(ymin, pts[i].y()); ymax = Math.max(ymax, pts[i].y()); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tc = sc.nextInt(); for (int t = 0; t < tc; t++) { int n = sc.nextInt(); Point[] pts = new Point[n]; for (int i = 0; i < n; i++) { pts[i] = new Point(sc.nextInt(), sc.nextInt()); } Rect rc = new Rect(pts); if (rc.allPointOnBoundary()) { System.out.println("YES"); } else { System.out.println("NO"); } } } public boolean allPointOnBoundary() { boolean[] all = new boolean[pts.length]; // marking for (int i = 0; i < pts.length; i++) { Point pt = pts[i]; if (pt.x() == xmin || pt.x() == xmax) { if (pt.y() >= ymin && pt.y() <= ymax) { all[i] = true; } } if (pt.y() == ymin || pt.y() == ymax) { if (pt.x() >= xmin && pt.x() <= xmax) { all[i] = true; } } } for (int i = 0; i < pts.length; i++) { if (! all[i]) return false; } return true; } } class Point { private int x; private int y; public Point(int x, int y) { this.x = x; this.y = y; } public int x() { return x; } public int y() { return y; } }