use std::io; use std::io::prelude::*; use std::collections::HashSet; fn main() { let stdin = io::stdin(); let mut stdin_it = stdin.lock().lines(); let num_of_queries = stdin_it.next().unwrap().unwrap().parse::().unwrap(); for _ in 0 .. num_of_queries { let n = stdin_it.next().unwrap().unwrap().parse::().unwrap(); let mut points = Vec::new(); for _ in 0 .. n { let line = stdin_it.next().unwrap().unwrap(); let mut it = line.split_whitespace().map(|x| x.parse::().unwrap()); let (x, y) = (it.next().unwrap(), it.next().unwrap()); points.push((x, y)); } let x_min = points.iter().cloned().map(|p| p.0).min().unwrap(); let x_max = points.iter().cloned().map(|p| p.0).max().unwrap(); let y_min = points.iter().cloned().map(|p| p.1).min().unwrap(); let y_max = points.iter().cloned().map(|p| p.1).max().unwrap(); if points.into_iter().all(|p| p.0 == x_min || p.0 == x_max || p.1 == y_min || p.1 == y_max) { println!("YES"); } else { println!("NO"); } } }