import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner scan = new Scanner(System.in); // number of queries int q = scan.nextInt(); for (int i = 0; i < q; i++) { //number of points in the query int n = scan.nextInt(); int x = scan.nextInt(); int y = scan.nextInt(); for (int j = 0; j < n-1; j++) { int x1 = scan.nextInt(); int y1 = scan.nextInt(); if (x != x1 && y != y1){ System.out.println("NO"); return; } } System.out.println("YES"); } } }