#include #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; int n; while(q--) { cin>>n; int x[n],y[n]; set s1,s2; for(int i=0;i>x[i]>>y[i]; s1.insert(x[i]); s2.insert(y[i]); } int f=0; if(s1.size()<=2 && s2.size()<=2 && (s1.size() == s2.size())) { auto i=s1.begin(); auto j=s2.begin(); for(;i!=s1.end();i++,j++) { if((*i) != (*j)) { f=1; break; } } } else { f=1; } if(f==0) { cout<<"YES\n"; } else { cout<<"NO\n"; } } return 0; }