#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int q; int n; cin >> q; for (int query = 0; query < q; query++) { cin >> n; // # of points in the query int num = 0; int xMin, xMax, yMin, yMax; // Stores the range of values x and y could be vector> points; // Vector of size n while (num < n) { int x, y; cin >> x >> y; // Grabs the x and the y if (num == 0) // The first pair { xMin = x; xMax = x; yMin = y; yMax = y; } // Re-adjust x range if (x < xMin) xMin = x; else if (x > xMax) xMax = x; // Re-adjust y range if (y < xMin) yMin = y; else if (y > yMax) yMax = y; points.push_back(make_pair(x, y)); // Adds the coordinates to the vector num++; } // Check the points to see if they are part of the rectangle int i = 0; bool isRect = true; while (i < n && isRect) { pair point = points.at(i); // cout << "Checking point: (" << point.first << ", " << point.second << ")" << endl; // Check if the x or y coordinate is not equal if (point.first != xMin && point.first != xMax && point.second != yMin && point.second != yMax) { isRect = false; } i++; } if (isRect) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }