import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner in = new Scanner(System.in); int q = in.nextInt(); while(q-->0) { int n = in.nextInt(); int xMax = Integer.MIN_VALUE; int xMin = Integer.MAX_VALUE; int yMax = Integer.MIN_VALUE; int yMin = Integer.MAX_VALUE; List p = new LinkedList(); for (int i = 0; i < n; i++) { int x = in.nextInt(); int y = in.nextInt(); if (x > xMax) xMax = x; if (x < xMin) xMin = x; if (y > yMax) yMax = y; if (y < yMin) yMin = y; p.add(new Pos(x,y)); } boolean ans = true; for (Pos c : p) { if (c.x != xMax && c.x != xMin && c.y != yMax && c.y != yMin) { ans = false; break; } } System.out.println(ans ? "YES" : "NO"); } } } class Pos { int x; int y; public Pos(int x, int y) { this.x = x; this.y = y; } }