#pragma comment(linker, "/STACK:66777216") #pragma warning(disable : 4996) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #pragma hdrstop static constexpr int INF = 0x3f3f3f3f; #include #ifdef _MSC_VER #include #else #define popcount(a) __builtin_popcount(a) #define clz(a) __builtin_clz(a) #define ctz(a) __builtin_ctz(a) #endif template inline bool umin(T& a, const T& b) { return (b < a ? a = b, true : false); } template inline bool umax(T& a, const T& b) { return (a < b ? a = b, true : false); } #ifdef _MSC_VER #endif template struct MakeVector { }; template struct MakeVector { /// caide keep template> static R make_vector(std::size_t size, const T& value) { return R(size, value); } }; #ifdef _MSC_VER #else #define LLD "%lld" #define LLU "%llu" #endif #define pii std::pair namespace std { template std::istream& operator>>(std::istream& in, std::vector& vec) { for (auto& it : vec) { in >> it; } return in; } template std::istream& operator>>(std::istream& in, std::pair& rhs) { in >> rhs.first >> rhs.second; return in; } } // namespace std #include template class IntegerIterator : public std::iterator { public: using value_type = T; constexpr explicit IntegerIterator(const value_type value) : value_(value) {} IntegerIterator& operator++() { ++value_; return *this; } constexpr value_type operator*() const { return value_; } constexpr bool operator ==(const IntegerIterator rhs) const { return value_ == rhs.value_; } constexpr bool operator !=(const IntegerIterator rhs) const { return !(*this == rhs); } private: value_type value_; }; template class IntegerRange { public: using const_iterator = IntegerIterator; constexpr IntegerRange(const T begin, const T end) : begin_(begin), end_(end) {} constexpr const_iterator begin() const { return const_iterator(begin_); } constexpr const_iterator end() const { return const_iterator(end_); } private: T begin_; T end_; }; template constexpr IntegerRange range(const T to) { return IntegerRange(0, to); } using namespace std; int __; void solve(std::istream& in, std::ostream& out) { in >> __; for (int _ : range(__)) { int n; in >> n; vector a(n); in >> a; int minx = INF; int miny = INF; int maxx = -INF; int maxy = -INF; for (const auto& it : a) { umax(maxx, it.first); umax(maxy, it.second); umin(minx, it.first); umin(miny, it.second); } bool ok = true; for (const auto& it : a) { ok &= (it.first == maxx || it.first == minx || it.second == maxy || it.second == miny); } out << (ok ? "YES" : "NO") << endl; } } #include int main() { srand(time(NULL)); ios_base::sync_with_stdio(0); cin.tie(0); istream& in = cin; ostream& out = cout; out << fixed << setprecision(16); solve(in, out); return 0; }