import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Solution { /// GENERIC PART public static void main(String[] args) throws IOException { init(System.in); solve(); } private static BufferedReader reader; private static StringTokenizer tokenizer; private static void init(InputStream input) { reader = new BufferedReader(new InputStreamReader(input)); tokenizer = new StringTokenizer(""); } private static String next() throws IOException { while (!tokenizer.hasMoreTokens()) { tokenizer = new StringTokenizer(reader.readLine()); } return tokenizer.nextToken(); } private static int nextInt() throws IOException { return Integer.parseInt(next(), 10); } private static int nextInt(int radix) throws IOException { return Integer.parseInt(next(), radix); } private static int[] nextInts(int n) throws IOException { final int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } return a; } private static double nextDouble() throws IOException { return Double.parseDouble(next()); } /// SOLUTION PART private static void solve() throws IOException { int q = nextInt(), n, t1, t2; int g[][]; query: while (q-- != 0) { n = nextInt(); g = new int[n][2]; for (int i = 0; i < n; i++) { t1 = nextInt(); t2 = nextInt(); g[i][0] = t1; g[i][1] = t2; } int minx = Integer.MAX_VALUE; int miny = Integer.MAX_VALUE; int maxx = Integer.MIN_VALUE; int maxy = Integer.MIN_VALUE; for (int i = 0; i < n; i++) { if (g[i][0] > maxx) maxx = g[i][0]; if (g[i][0] < minx) minx = g[i][0]; if (g[i][1] > maxy) maxy = g[i][1]; if (g[i][1] < miny) miny = g[i][1]; } for (int i = 0; i < n; i++) { if (!(g[i][0] == minx || g[i][0] == maxx) && !(g[i][1] == miny || g[i][1] == maxy)) { System.out.println("NO"); continue query; } } System.out.println("YES"); } } }