#include #include #include // #include using namespace std; using namespace __gnu_pbds; template ostream& operator<<(ostream& out, const pair& a) {out << "[" << a.first << " " << a.second << "]"; return out;} template ostream& operator<<(ostream& out, const vector& a) {out << "[ "; for (auto &it : a)out << it << " "; out << "]"; return out;} template ostream& operator<<(ostream& out, const set& a) {out << "[ "; for (auto &it : a)out << it << " "; out << "]"; return out;} template ostream& operator<<(ostream& out, const multiset& a) {out << "[ "; for (auto &it : a)out << it << " "; out << "]"; return out;} template ostream& operator<<(ostream& out, const map& a) {for (auto &it : a)out << it.first << " -> " << it.second << " | "; return out;} template ostream& operator<<(ostream& out, const multimap& a) {for (auto &it : a)out << it.first << " -> " << it.second << " | "; return out;} #define TRACE #ifdef TRACE #define cerr cout #define pra(a,n) cerr<<#a<<" : ";for(int i=0;i void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << std::endl; } template void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } #undef cerr #else #define pr(...) #define pra(a,n) #define praa(a,n,m) #endif #define inc_stack_limit const rlim_t kStackSize = 64 * 1024 * 1024;struct rlimit rl;rl.rlim_cur = kStackSize;setrlimit(RLIMIT_STACK, &rl); #define all(x) (x).begin(), (x).end() #define nall(x) (x).rbegin(), (x).rend() #define sz(a) int((a).size()) #define pres(s,x) (s.find(x)!=s.end()) #define pb push_back #define MP make_pair #define F first #define S second #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define NFOR(i,a,b) for(int i=(a);i>=(b);--i) #define rep(n) FOR (_, 0, (n) - 1) #define TCASE int __T;cin>>__T;FOR(Tc,1,__T) typedef tree, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef long long ll; typedef vector vi; typedef vector vll; typedef vector vvll; typedef vector > vvi; typedef pair ii; typedef vector > vii; typedef vector > > vvii; const ll inf2 = 1e18; const int inf = 1e9 + 7; inline int add(int a, int b, int m = inf) {a += b; if (a >= m)a -= m; return a;} inline int sub(int a, int b, int m = inf) {a -= b; if (a < 0)a += m; return a;} inline int mul(int a, int b, int m = inf) {return (int)(((ll)a * (ll)b) % m);} int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); TCASE { int n; cin >> n; vii p(n); int mx = inf, MX = -inf, my = inf, MY = -inf; FOR (i, 0, n - 1) cin >> p[i].F >> p[i].S, mx = min(p[i].F, mx), MX = max(p[i].F, MX), my = min(my, p[i].S), MY = max(MY, p[i].S); bool can = 1; FOR (i, 0, n - 1) { can &= (p[i].F == mx or p[i].F == MX or p[i].S == my or p[i].S == MY); } if (!can) { cout << "NO\n";continue; } cout << "YES\n"; } return 0; }