import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int q = scanner.nextInt(); for (int it = 0; it < q; it++) { int i = scanner.nextInt(); if (i <= 3) { System.out.println("YES"); for (int j = 0; j < i; j++) { scanner.nextInt(); scanner.nextInt(); } continue; } List points = new ArrayList<>(); int minx = 0; int miny = 0; int maxx = 0; int maxy = 0; if (i > 0) { int x = scanner.nextInt(); int y = scanner.nextInt(); points.add(new Integer[] {x, y}); minx = x; maxx = x; miny = y; maxy = y; } for (int j = 1; j < i; j++) { int x = scanner.nextInt(); int y = scanner.nextInt(); points.add(new Integer[] {x, y}); if (x < minx) { minx = x; } else if (x > maxx) { maxx = x; } if (y < miny) { miny = y; } else if (y > maxy) { maxy = y; } } boolean result = true; for (Integer[] ints : points) { if ((ints[0] != minx && ints[0] != maxx) || (ints[1] != miny && ints[1] != maxy)) { result = false; } } System.out.println(result ? "YES" : "NO"); } } }