import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; 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. */ BufferedReader in = null; long answer = 0; int queries = 0; try { in = new BufferedReader(new InputStreamReader(System.in)); queries = Integer.parseInt(in.readLine()); int points = 0; for (int i = 0; i < queries; i++) { points = Integer.parseInt(in.readLine()); String[] pointArr = in.readLine().split(" "); int x = Integer.parseInt(pointArr[0]); int y = Integer.parseInt(pointArr[1]); boolean yes = true; for (int j = 1; j < points; j++) { String[] mPointArr = in.readLine().split(" "); if ((Integer.parseInt(mPointArr[0]) != x) && (Integer.parseInt(mPointArr[1]) != y)) { yes = false; break; } } if (yes) System.out.println("YES"); else System.out.println("NO"); } } catch (IOException e) { e.printStackTrace(); } finally { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } } }