import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { PrintWriter output = new PrintWriter(System.out); new Solution().processInput(new Scanner(System.in), output); output.flush(); } public void processInput(Scanner in, PrintWriter output) { int q = in.nextInt(); // for (int i = 0; i < q; i++) { int n = in.nextInt(); // int[] X = new int[n]; int[] Y = new int[n]; ArrayList points = new ArrayList<>(); TreeSet treeSet = new TreeSet<>(); int minX = Integer.MAX_VALUE; int maxX = Integer.MIN_VALUE; int minY = Integer.MAX_VALUE; int maxY = Integer.MIN_VALUE; for (int j = 0; j < n; j++) { int x = in.nextInt(); // int y = in.nextInt(); if (x < minX) minX = x; if (x > maxX) maxX = x; if (y < minY) minY = y; if (y > maxY) maxY = y; X[j] = x; Y[i] = y; Point p = new Point(x,y); points.add(p); treeSet.add(p); } output.println(allTEdge(points, treeSet, minX, minY, maxX, maxY) ? "YES" : "NO"); } } private boolean allTEdge(ArrayList points, TreeSet treeSet, int minX, int minY, int maxX, int maxY) { for (Point point : points) { if (point.x != maxX && point.x != minX) return false; if (point.y != maxY && point.y != minY) return false; } return true; // if (points.size()<3) return false; // Iterator iterator = treeSet.iterator(); // // Slope slopeA = null; // Slope slopeB = null; // Slope slopeC = null; // Slope slopeD = null; // Point first = iterator.next(); // while (iterator.hasNext()) { // Point next = iterator.next(); // if (next.equals(first)) continue; // if (slopeA == null) { // slopeA = new Slope(first, next); // } else if (!slopeA.includes(next)) { // // } // } // Point next = iterator.next(); // return true; } private class Point implements Comparable { private final int x, y; public Point(int x, int y) { this.x = x; this.y = y; } @Override public int compareTo(Point o) { return this.x - o.x; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Point point = (Point) o; if (x != point.x) return false; return y == point.y; } @Override public int hashCode() { int result = x; result = 31 * result + y; return result; } } private class Slope { private final int dx; private final int dy; private final Point anker; public Slope(Point a, Point b) { if (a.equals(b)) throw new IllegalStateException(); this.anker = a; this.dx = a.x - b.x; this.dy = a.y - b.y; } public boolean includes(Point point) { if (anker.equals(point)) return true; // anker.x - point.x return false; } } }