import java.io.*; import java.util.*; import java.math.*; public class hack42Q2 { public static void main(String[] args) throws IOException { FastScanner obj = new FastScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int q = obj.nextInt(); while(q-->0) { int n = obj.nextInt(); int x = obj.nextInt(); int y = obj.nextInt(); String ans=""; while(n-->1) { int x2 = obj.nextInt(); int y2 = obj.nextInt(); if(x2==x || y2==y) ans= "YES"; else { ans="NO"; break; } } out.println(ans); } out.close(); } //-----------PrintWriter for faster output--------------------------------- public static PrintWriter out; //-----------FastScanner class for faster input---------- public static class FastScanner { BufferedReader br; StringTokenizer tokenizer; public FastScanner() throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); tokenizer = new StringTokenizer(br.readLine().trim()); } String next() { while (tokenizer == null || !tokenizer.hasMoreElements()) { try { tokenizer = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return tokenizer.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } int[] nextIntArray() throws IOException { String[] line = br.readLine().trim().split(" "); int[] out = new int[line.length]; for (int i = 0; i < line.length; i++) { out[i] = Integer.valueOf(line[i]); } return out; } BigInteger nextBigInteger() throws IOException { return new BigInteger(next()); } String nextLine(){ String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } //-------------------------------------------------------- }