using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ var q = int.Parse(Console.ReadLine()); for (var qi = 0; qi < q; qi++) { var n = int.Parse(Console.ReadLine()); var points = Enumerable.Range(0, n).Select(ni => Console.ReadLine().Split(' ').Select(int.Parse).ToArray()).ToArray(); var xMax = points.Max(p => p[0]); var xMin = points.Min(p => p[0]); var yMax = points.Max(p => p[1]); var yMin = points.Min(p => p[1]); var YES = points.All(p => ((p[0] == xMin || p[0] == xMax) && (p[1] >= yMin || p[1] <= yMax)) || ((p[1] == yMin || p[1] == yMax) && (p[0] >= xMin || p[0] <= xMax)) ); Console.WriteLine(YES ? "YES" : "NO"); } } }