import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; public class Solution { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int q = Integer.parseInt(br.readLine()); for (int i = 0; i < q; i++) { int n = Integer.parseInt(br.readLine()); int[][] vals = new int[n][2]; for (int j = 0; j < n; j++) { String[] strs = br.readLine().split(" "); vals[j][0] = Integer.parseInt(strs[0]); vals[j][1] = Integer.parseInt(strs[1]); } solve(vals); } } private static Comparator COMPARATOR1 = new Comparator() { @Override public int compare(int[] o1, int[] o2) { if (o1[0] == o2[0]) { return Integer.compare(o1[1], o2[1]); } else { return Integer.compare(o1[0], o2[0]); } } }; private static Comparator COMPARATOR2 = new Comparator() { @Override public int compare(int[] o1, int[] o2) { if (o1[1] == o2[1]) { return Integer.compare(o1[0], o2[0]); } else { return Integer.compare(o1[1], o2[1]); } } }; private static void solve(int[][] vals) { int[][] valsx = vals; int[][] valsy = vals.clone(); Arrays.sort(valsx, COMPARATOR1); Arrays.sort(valsy, COMPARATOR2); int x1 = valsx[0][0]; int x2 = valsx[vals.length - 1][0]; int y1 = valsy[0][1]; int y2 = valsy[vals.length - 1][1]; if ((x1 == 0 && x2 == 0) || (y1 == 0 && y2 == 0)) { System.out.println("NO"); // degenerate return; } for (int[] val : vals) { if (val[0] != x1 && val[0] != x2 && val[1] != y1 && val[1] != y2) { System.out.println("NO"); return; } } System.out.println("YES"); } }