import java.util.Arrays; import java.util.Scanner; public class POAR { public static void main(String[] arg) { new POAR().testCPS(); } private void testCPS() { Scanner scan = new Scanner(System.in); long T = scan.nextLong(); for (long t = 0; t < T; t++) { System.out.println(CPS(scan)); } } private String CPS(Scanner scan) { int n = scan.nextInt(); if (n == 1) { scan.nextLong(); scan.nextLong(); return "YES"; } long x = scan.nextLong(); long y = scan.nextLong(); long miX = x; long maX = x; long miY = y; long maY = y; Point[] a = new Point[n]; a[0] = new Point(x, y); for (int i = 1; i < n; i++) { x = scan.nextLong(); y = scan.nextLong(); miX = Math.min(miX, x); maX = Math.max(maX, x); miY = Math.min(miY, y); maY = Math.max(maY, y); a[i] = new Point(x, y); } for (int i = 0; i < n; i++) { if (a[i].x == miX || a[i].x == maX) { if (!(a[i].y <= maY) || !(a[i].y >= miY)) { return "NO"; } } else if (a[i].y == miY || a[i].y == maY) { if (!(a[i].x <= maX) && !(a[i].x >= miX)) { return "NO"; } } else { return "NO"; } } return "YES"; } private class Point { long x; long y; public Point() { } public Point(long x, long y) { this.x = x; this.y = y; } } }