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. */ Scanner sc = new Scanner(System.in); int queries = sc.nextInt(); for(int i = 0; i < queries; i++){ int points = sc.nextInt(); HashMap xMap = new HashMap(); HashMap yMap = new HashMap(); Integer frequency = null; for(int j = 0; j < points; j++){ int temp = sc.nextInt(); frequency = xMap.get(temp); if(frequency == null) xMap.put(temp, 1); else xMap.put(temp, frequency + 1); int tempY = sc.nextInt(); frequency = yMap.get(tempY); if(frequency == null) yMap.put(tempY, 1); else yMap.put(tempY, frequency + 1); } if(xMap.keySet().size() <= 2 || yMap.keySet().size() <= 2) System.out.println("YES"); else System.out.println("NO"); } } }