using System; using System.Collections.Generic; using System.IO; 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 queries = Convert.ToInt32(Console.ReadLine()); for( int i = 0; i < queries; i++) { var numPoints = Convert.ToInt32(Console.ReadLine()); var maxValue = 0; var minValue = 0; var output = "YES"; for (int j = 0; j < numPoints; j++) { var positions = Console.ReadLine().Split(' '); var x = Convert.ToInt32(positions[0]); var y = Convert.ToInt32(positions[1]); maxValue = x > maxValue ? x : maxValue; minValue = x < minValue ? x : minValue; maxValue = y > maxValue ? y : maxValue; minValue = y < minValue ? y : minValue; if ((x != maxValue && x!= minValue) || (y != maxValue && y != minValue)) { output = "NO"; break; } } Console.WriteLine(output); } } }