import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int q = sc.nextInt(); for (int qq = 0; qq < q; qq++) { int n = sc.nextInt(); ArrayList a = new ArrayList(); ArrayList b = new ArrayList(); for (int i = 0; i < n; i++) { int x = sc.nextInt(); a.add(x); int y = sc.nextInt(); b.add(y); } ArrayList aa =(ArrayList) a.clone(); ArrayList bb =(ArrayList) b.clone(); Collections.sort(a); Collections.sort(b); int xmin = a.get(0), xmax = a.get(a.size() -1 ); int ymin = b.get(0), ymax = b.get(b.size() -1 ); boolean res = true; for (int i = 0, leng = a.size() ; i < leng; i++) { if (aa.get(i) != xmin && aa.get(i) != xmax && bb.get(i) != ymin && bb.get(i) != ymax) res = false; } if (res) System.out.println("YES"); else System.out.println("NO"); } } }