using System; using System.Linq; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { int tc = Convert.ToInt32(Console.ReadLine()); for (int t = 0; t < tc; t++) { int nop = Convert.ToInt32(Console.ReadLine()); int[] xs = new int[nop]; int[] ys = new int[nop]; for (int i = 0; i < nop; i++) { int[] ps = Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32); xs[i] = ps[0]; ys[i] = ps[1]; } int minx = xs.Min(); int maxx = xs.Max(); int miny = ys.Min(); int maxy = ys.Max(); bool result = true; for (int i = 0; i < nop; i++) { int x = xs[i]; int y = ys[i]; if (x >= minx && x <= maxx && (y == miny || y == maxy)) continue; else if (y >= miny && y <= maxy && (x == maxx || x == minx)) continue; else { result = false; break; } } Console.WriteLine(result ? "YES" : "NO"); } } }