#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define f(i,a,b) for(ll i=a;i=b;i--) #define ff(i,a,b,c) for(int i=a;i0) #define vi vector #define vll vector typedef pair P; typedef pair ,int> PII; typedef pair ,long long int> PLL; typedef pair PL; typedef long long ll; typedef long double ld; typedef int I; typedef string S; ll gcd(ll n,ll m){if(m<=n && n%m==0)return m;if(nn-r)r=n-r;f(i,1,r+1)ans=(ans*(n-i+1))/(i);return ans;} ll mul(ll a,ll b,ll mod){a%=mod;b%=mod;ld res=a;res*=b;ll c=(ll)(res/mod);a*=b;a-=c*mod;a%=mod;if(a<0)a+=mod;return a;} ll mod_pow(ll a,ll b,ll mod){ll ans=1;while(b){if(b&1)ans=mul(ans,a,mod);a=mul(a,a,mod);b>>=1;}return ans;} ll div(ll x,ll y,ll mod){return mul(x,mod_pow(y,mod-2,mod),mod);} int main(){ ll q , n , x , y ; map< ll , I > mp1 , mp2; cin >> q; w( q ) { q-- ; cin >> n ; f(i, 0, n ) { cin >> x >> y ; mp1[ x ] = 1; mp2[ y ] = 1; } if( mp1.size() > 2 || mp2.size() > 2 ) cout << "NO" << endl; else cout << "YES" << endl; mp1.clear(); mp2.clear(); } }