#include using namespace std; typedef long long int ll; #define pb push_back #define mp make_pair #define fi first #define se second void init() { int q,n,x,y,i; cin >> q; while(q--) { vector X,Y; cin >> n; for(i=0;i> x >> y ; X.pb(x); Y.pb(y); } if(n==1 || n==2) cout << "YES\n"; else { //sort(X.begin(),X.end()); //sort(Y.begin(),Y.end()); int x1=*min_element(X.begin(),X.end()); int x2=*max_element(X.begin(),X.end()); int y1=*min_element(Y.begin(),Y.end()); int y2=*max_element(Y.begin(),Y.end()); if(x1==x2 || y1==y2) cout << "YES\n"; else { /*int x1=X[0]; int x2=X[n-1]; int y1=Y[0]; int y2=Y[n-1];*/ int flag=0; for(i=0;ix1 && Y[i]y1) { flag=1; break; } } if(flag==1) cout << "NO\n"; else cout << "YES\n"; } } } } int main() { clock_t time1 = clock(); #ifndef ONLINE_JUDGE //freopen("IN.in","r",stdin); #else //ONLINE_JUDGE #endif ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); init(); clock_t time2 = clock(); cerr <<"Time: " <<(double)(time2-time1)/CLOCKS_PER_SEC * 100000 <<" seconds" <