import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int Q = sc.nextInt(); for (int q = 0; q < Q; q++) { int n = sc.nextInt(); List points = new ArrayList<>(); for (int i = 0; i < n; i++) { points.add(new Coordinate(sc.nextInt(), sc.nextInt())); } System.out.println(solution(points)); } } public static String solution(List points) { Rectangle rect = new Rectangle(getTop(points), getRight(points), getBottom(points), getLeft(points)); for (Coordinate point: points) { if (!rect.hasInBorder(point)) return "NO"; } return "YES"; } public static Coordinate getTop(List points) { Coordinate top = points.get(0); for (Coordinate point: points) { if (point.y > top.y) top = point; } return top; } public static Coordinate getRight(List points) { Coordinate right = points.get(0); for (Coordinate point: points) { if (point.x > right.x) right = point; } return right; } public static Coordinate getBottom(List points) { Coordinate bottom = points.get(0); for (Coordinate point: points) { if (point.y < bottom.y) bottom = point; } return bottom; } public static Coordinate getLeft(List points) { Coordinate left = points.get(0); for (Coordinate point: points) { if (point.x < left.x) left = point; } return left; } public static class Rectangle { public final Coordinate top; public final Coordinate right; public final Coordinate bottom; public final Coordinate left; public Rectangle(Coordinate top, Coordinate right, Coordinate bottom, Coordinate left) { this.top = top; this.right = right; this.bottom = bottom; this.left = left; } public boolean hasInBorder(Coordinate p) { return ((p.x == left.x || p.x == right.x) && (bottom.y <= p.y && p.y <= top.y)) || ((p.y == bottom.y || p.y == top.y) && (left.x <= p.x && p.x <= right.x)); } } public static class Coordinate { public final int x; public final int y; public Coordinate(int x, int y) { this.x = x; this.y = y; } } }