import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); PointsOnRectangle solver = new PointsOnRectangle(); solver.solve(1, in, out); out.close(); } static class PointsOnRectangle { public void solve(int testNumber, Scanner in, PrintWriter out) { int q = in.nextInt(); for (int i = 0; i < q; i++) { int n = in.nextInt(); int points[][] = new int[n][2]; for (int j = 0; j < n; j++) { for (int k = 0; k < 2; k++) { points[j][k] = in.nextInt(); } } if (isCorrect(points)) { out.println("YES"); } else { out.println("NO"); } } } public boolean isCorrect(int[][] points) { int max = Integer.MIN_VALUE; int min = Integer.MAX_VALUE; int len = points.length; int min_x = 0; int min_y = 0; int max_x = 0; int max_y = 0; int d_min = min; for (int i = 0; i < len; i++) { if (points[i][0] < d_min) { d_min = points[i][0]; } } min_x = d_min; d_min = min; for (int i = 0; i < len; i++) { if (points[i][1] < d_min) { d_min = points[i][1]; } } min_y = d_min; d_min = min; int d_max = max; for (int i = 0; i < len; i++) { if (points[i][0] > d_max) { d_max = points[i][0]; } } max_x = d_max; d_max = max; for (int i = 0; i < len; i++) { if (points[i][1] > d_max) { d_max = points[i][1]; } } max_y = d_max; d_max = max; for (int i = 0; i < len; i++) { int x = points[i][0]; int y = points[i][1]; if (x == min_x || x == max_x) { if (!(y >= min_y && y <= max_y)) { return false; } } else if (x > min_x && x < max_x) { if (!(y == min_y || y == max_y)) { return false; } } } return true; } } }