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 z = 0; z < q; z++) { int n = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; int minx = 1000000; int miny = 1000000; int maxx = -1000000; int maxy = -1000000; for (int i = 0; i < n; i++) { x[i] = sc.nextInt(); y[i] = sc.nextInt(); minx = Math.min(minx, x[i]); miny = Math.min(miny, y[i]); maxx = Math.max(maxx, x[i]); maxy = Math.max(maxy, y[i]); } String ans = "YES"; for (int i = 0; i < n; i++) { if (x[i]!=minx&&x[i]!=maxx&&y[i]!=miny&&y[i]!=maxy) ans = "NO"; } System.out.println(ans); } } }