#include #include #include #include #include #include #include using namespace std; typedef pair pii; bool f(const vector& points) { int minX = INT_MAX; int maxX = INT_MIN; int minY = INT_MAX; int maxY = INT_MIN; for (auto& p : points) { minX = min(minX, p.first); maxX = max(maxX, p.first); minY = min(minY, p.second); maxY = max(maxY, p.second); } // cout << minX << " " << maxX << " " << minY << " " << maxY << endl; for (auto& p : points) { if (p.first > minX && p.first < maxX) { if (p.second != minY && p.second != maxY) { return false; } } else { if (p.second < minY || p.second > maxY) { return false; } } } return true; } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int q; cin >> q; for (int q_ = 0; q_ < q; ++q_) { int n; cin >> n; vector points(n); for (int i = 0; i < n; ++i) { cin >> points[i].first >> points[i].second; } cout << (f(points) ? "YES" : "NO"); cout << endl; } return 0; }