#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int q; cin>>q; while(q--) { int n,i; cin>>n; pair p; vector> c; for(i=0;i>p.first; cin>>p.second; c.push_back(p); } if(n<=2) cout<<"YES\n"; else if(n==3) { int x,y,xc=0,yc=0; x=c[0].first; y=c[0].first; for(i=0;i=x1 && c[i].first<=x2 && (c[i].second==y1 || c[i].second==y2)) flag=1; else if(c[i].second>=y1 && c[i].second<=y2 && (c[i].first==x1 || c[i].first==x2)) flag=1; else { flag=0; break; } } if(flag==1) cout<<"YES\n"; else cout<<"NO\n"; } } return 0; }