using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Challenges._101Hack42 { class Solution { public static void Main(string[] args) { int rounds = Convert.ToInt32(Console.ReadLine()); for (int r = 0; r < rounds; r++) { int points = Convert.ToInt32(Console.ReadLine()); List> list = new List>(); for (int p = 0; p < points; p++) { int[] point = Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32); list.Add(new Tuple(point[0], point[1])); } Console.WriteLine(ArePointsOnRectangle(list)); } } private static string ArePointsOnRectangle(List> points) { int min_x = 0, max_x = 0; int min_y = 0, max_y = 0; foreach (Tuple point in points) { if (point.Item1 < min_x) min_x = point.Item1; else if (point.Item1 > max_x) max_x = point.Item1; if (point.Item2 < min_y) min_y = point.Item2; if (point.Item2 > max_y) max_y = point.Item2; } //now that we've stretched our rectangle, calculate if all points lie on it. foreach (Tuple point in points) { if (!point.Item1.Equals(min_x) && !point.Item1.Equals(max_x)) return "NO"; if (!point.Item2.Equals(min_y) && !point.Item2.Equals(max_y)) return "NO"; } return "YES"; } } }