case class Point(x: Int, y: Int) { def this(a: Array[Int]) = this(a(0), a(1)) } object Solution { def main(args: Array[String]) { val q = io.StdIn.readInt; (1 to q).foreach{i => val n = io.StdIn.readInt; val points = (1 to n).map(k => io.StdIn.readLine.split(" ").map(_.toInt)) if (n == 1 || n == 2) { println("YES") } else { val p = points.map(x => Point(x(0), x(1))); val minX = p.map(i => i.x).min; val maxX = p.map(i => i.x).max; val minY = p.map(i => i.y).min; val maxY = p.map(i => i.y).max; val possible = p.forall(a => a.x == minX || a.x == maxX || a.y == minY || a.y == maxY) if (possible) println("YES") else println("NO") } } } }