using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Hack1 { struct Point { public int x, y; public static Point Read() { var ss = Console.ReadLine().Split( ' ' ).Select( s => int.Parse( s ) ).ToArray(); return new Point { x = ss[ 0 ], y = ss[ 1 ] }; } } class Program { const int Z = int.MaxValue; static void Main( string[] args ) { var N = int.Parse( Console.ReadLine() ); for (int n = 0; n < N; ++n) { var Q = int.Parse( Console.ReadLine() ); var lps = new List(); for (int q = 0; q < Q; ++q) lps.Add( Point.Read() ); var x1 = lps.Min( p => p.x ); var x2 = lps.Max( p => p.x ); var y1 = lps.Min( p => p.y ); var y2 = lps.Max( p => p.y ); bool ok = true; foreach (var p in lps) { if (p.x >= x1 && p.x <= x2 && (p.y == y1 || p.y == y2)) continue; if (p.y >= y1 && p.y <= y2 && (p.x == x1 || p.x == x2)) continue; ok = false; break; } Console.WriteLine( ok ? "YES" : "NO" ); } } } }