import java.io.*; import java.util.*; 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) { solve(in); } } private static void solve(Scanner in) { int n = in.nextInt(); int[] x = new int[n]; int[] y = new int[n]; final int INF = 100000; int lx = INF; int ly = INF; int rx = -INF; int ry = -INF; for (int i = 0; i < n; ++i) { x[i] = in.nextInt(); y[i] = in.nextInt(); lx = Math.min(lx, x[i]); ly = Math.min(ly, y[i]); rx = Math.max(rx, x[i]); ry = Math.max(ry, y[i]); } boolean ok = true; for (int i = 0; i < n; ++i) { if (x[i] == lx || x[i] == rx) { ok &= (ly <= y[i] && y[i] <= ry); } else { ok &= (y[i] == ly || y[i] == ry); ok &= (lx <= x[i] && x[i] <= rx); } } System.out.println(ok ? "YES" : "NO"); } }