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 in = new Scanner(System.in); int t = in.nextInt(); outerloop: while (t-- > 0){ int n = in.nextInt(); int minx = Integer.MAX_VALUE; int maxx = Integer.MIN_VALUE; int miny = Integer.MAX_VALUE; int maxy = Integer.MIN_VALUE; Point[] p = new Point[n]; for (int i = 0; i < n; i++){ p[i] = new Point(in.nextInt(), in.nextInt()); if (minx > p[i].x) minx = p[i].x; if (maxx < p[i].x) maxx = p[i].x; if (miny > p[i].y) miny = p[i].y; if (maxy < p[i].y) maxy = p[i].y; } for (Point po : p){ if (po.x != minx && po.x != maxx && po.y != miny && po.y != maxy){ System.out.println("NO"); continue outerloop; } } System.out.println("YES"); } } } class Point{ public int x; public int y; public Point(int x, int y){ this.x = x; this.y = y; } }