#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define X first #define Y second #define mp make_pair #define pb push_back #define pdd pair #define pii pair #define PI 3.14159265358979323846 #define MOD 1000000007 #define MOD2 1000000009 #define INF ((ll)1e+18) #define x1 fldgjdflgjhrthrl #define x2 fldgjdflgrtyrtyjl #define y1 fldggfhfghjdflgjl #define y2 ffgfldgjdflgjl #define N 202100 #define SUM 23423 #define MAG 333 typedef long long ll; typedef long double ld; using namespace std; ll i,j,n,k,l,m,x,y,tot, flag,h,r,ans,koko,z,nl,nr,maxx,maxy,minx,miny; ll a[100500], b[100500], used[100500]; ll Abs(ll x) { return x>0?x:-x; } int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); ll tests; cin >> tests; while (tests--) { maxx=maxy = -MOD; minx=miny=MOD; cin >> n; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; maxx = max(maxx, a[i]); maxy = max(maxy, b[i]); minx = min(minx, a[i]); miny = min(miny, b[i]); } ll flag = 1; for (i = 0; i < n; i++) { int cur = 0; if (a[i] == maxx && b[i] >= miny && b[i] <= maxy || a[i] == minx && b[i] >= miny && b[i] <= maxy || b[i] == maxy && a[i] >= minx && a[i] <= maxx || b[i] == miny && a[i] >= minx && a[i] <= maxx) cur = 1; flag &= cur; } if (flag) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }