using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace rect { class Program { static void Main(string[] args) { int nCases = int.Parse(Console.ReadLine()); for (int nCase = 0; nCase < nCases; nCase++) { string answer = "NO"; int numberOfPoints = int.Parse(Console.ReadLine()); var points = new List(); int minX = int.MaxValue, minY = int.MaxValue, maxX = int.MinValue, maxY = int.MinValue; for (int i = 0; i < numberOfPoints; i++) { int[] point = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); if (minX > point[0]) { minX = point[0]; } if (maxX < point[0]) { maxX = point[0]; } if (minY > point[1]) { minY = point[1]; } if (maxY < point[1]) { maxY = point[1]; } points.Add(point); } int pointsOK=0; for (int pointIndex = 0; pointIndex < points.Count; pointIndex++) { if (points[pointIndex][0] == maxX) { if (points[pointIndex][1] >= minY || points[pointIndex][1] <= minY) { pointsOK++; } } else if (points[pointIndex][0] == minX) { if (points[pointIndex][1] >= minY || points[pointIndex][1] <= minY) { pointsOK++; } } else if (points[pointIndex][1] == maxY) { if (points[pointIndex][0] >= minX || points[pointIndex][0] <= minX) { pointsOK++; } } else if (points[pointIndex][1] == minY) { if (points[pointIndex][0] >= minX || points[pointIndex][0] <= minX) { pointsOK++; } } else { break; } } if (pointsOK == points.Count) { answer = "YES"; } Console.WriteLine(answer); } } } }