using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Problem2 { class Program { static void Main(string[] args) { var q = rl(); for (long i = 0; i < q; i++) { Solve(); } } struct Point { public long X { get; set; } public long Y { get; set; } } public static void Solve() { var n = rl(); List ps = new List(); for (int i = 0; i < n; i++) { var pLine = rla(); ps.Add(new Point { X = pLine[0], Y = pLine[1] }); } var yMin = ps.Select(x => x.Y).Min(); var yMax = ps.Select(x => x.Y).Max(); var xMin = ps.Select(x => x.X).Min(); var xMax = ps.Select(x => x.X).Max(); foreach (var p in ps) { if (p.Y == yMax || p.Y == yMin) { if (!(p.X <= xMax && p.X >= xMin)) { Console.WriteLine("NO"); return; } } else { if ((p.X != xMax) && (p.X!= xMin)) { Console.WriteLine("NO"); return; } } } Console.WriteLine("YES"); } #region Helper public static long rl() { return long.Parse(Console.ReadLine()); } public static long[] rla() { var line = Console.ReadLine().Split(' '); return Array.ConvertAll(line, long.Parse); } public static string[] rls() { return Console.ReadLine().Split(' '); } public static List GetBitList(long x) { //4 ~ 0 0 1 List bitList = new List(); while (x > 0) { bitList.Add((short)(x & 1)); x = x >> 1; } return bitList; } #endregion Helper } }