/* ta yag odo batorshihiin code harj bn */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll MOD = 1000000009ll; const ll INFl = 9223372036854775807ll; const int inf = (1 << 30) - 1; #define ff first #define ss second #define pb push_back #define _N 100005 #define mk make_pair ll power(ll x, ll y, ll z) { ll t = 1; while (y > 0) { if (y % 2) { t = (t * x) % z; } x = (x * x) % z; y /= 2; } return t; } int movex[4] = {0, 1, -1, 0}; int movey[4] = {1, 0, 0, -1}; int n; const int af = 10000; bool M[af * 2 + 123][af * 2+123]; int X[af * 3] = {0}, Y[af * 3] = {0}; int main () { // freopen ("std.in", "r", stdin); // freopen ("std.out", "w", stdout); int q, i, j; int x, y; scanf ("%d", &q); while (q --) { scanf ("%d", &n); int ymin = af, xmin = af; int xmax = -af, ymax = -af; memset (M, 0, sizeof M); memset (X, 0, sizeof X); memset (Y, 0, sizeof Y); for (i = 0; i < n; i ++) { scanf ("%d%d", &x, &y); x += af; y += af; X[x] ++; Y[y] ++; M[x][y] = 1; ymin = min (ymin, y); ymax = max (ymax, y); xmin = min (xmin, x); xmax = max (xmax, x); } if (ymin == ymax || xmin == xmax) { printf ("YES\n"); continue; } int ans; ans = Y[ymin] + Y[ymax] + X[xmin] + X[xmax]; ans -= M[xmin][ymin]; ans -= M[xmin][ymax]; ans -= M[xmax][ymin]; ans -= M[xmax][ymax]; if (ans == n) printf ("YES\n"); else printf ("NO\n"); } return 0; }