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 q = in.nextInt(); for (int i = 0; i < q; i++) { int n = in.nextInt(); int points [][] = new int[n][2]; int x0 = in.nextInt(); int y0 = in.nextInt(); points[0][0] = x0; points[0][1] = y0; int top = y0; int bottom = y0; int left = x0; int right = x0; boolean onRect = true; for (int j = 1; j < n; j++) { int x = in.nextInt(); int y = in.nextInt(); points[j][0] = x; points[j][1] = y; boolean thisPointOk = false; if (x <= left) { thisPointOk = true; left = x; } else if (x >= right) { thisPointOk = true; right = x; } if (y <= bottom) { thisPointOk = true; bottom = y; } else if (y >= top) { thisPointOk = true; top = y; } if (!thisPointOk){ onRect = false; } } if (onRect) { for (int j = 0; j < n; j++) { int x = points[j][0]; int y = points[j][1]; if ((x != left && x != right) && (y != bottom && y!= top)) { onRect = false; break; } } } if (onRect) System.out.println("YES"); else System.out.println("NO"); } } }