#include using namespace std; #define MOD 1000000007 #define pb push_back #define mp make_pair #define all(c) (c).begin(),(c).end() #define sz(a) int((a).size()) #define F first #define S second #define rep(i, a, b) for(int i = a; i < b; ++i) #define per(i, a, b) for(int i = a; i >= b; --i) #define travel(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++) #define INDEX(arr,ind) (lower_bound(all(arr),ind)-arr.begin()) typedef long long ll; typedef long double ld; typedef vector vi; typedef pair pii; typedef pair pli; typedef pair pll; typedef pair piii; typedef pair plll; typedef vector vpii; typedef vector vpiii; inline ll powmod(ll x, ll n, ll _mod){ ll res = 1; while (n){ if (n & 1)res = (res*x) % _mod; x = (x*x) % _mod; n >>= 1; } return res; } #define N 100005 int q; pii pts[100]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("in.txt","r",stdin); // freopen("o.txt","w",stdout); cin>>q; while(q--){ int n; cin>>n; int x1=1e9; int y1=1e9; int x2=-1e9; int y2=-1e9; rep(i,0,n){ cin>>pts[i].F>>pts[i].S; x1=min(x1,pts[i].F); x2=max(x2,pts[i].F); y1=min(y1,pts[i].S); y2=max(y2,pts[i].S); } bool ok=true; rep(i,0,n){ int x=pts[i].F; int y=pts[i].S; if(x==x1 or x==x2){ if(y1<=y and y<=y2)continue; else ok=0; } else if(y==y1 or y==y2){ if(x1<=x and x<=x2)continue; else ok=0; } else ok=0; } if(!ok)cout<<"NO\n"; else cout<<"YES\n"; } return 0; }