// *** Copyright@RjStyles *** // #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define pb(val) push_back(val) #define ull unsigned long long #define ll long long #define rep(i, s, e) for(int i=s; i #define all(a) a.begin(), a.end() templatevoid read(T &x) { register T c = getchar_unlocked(); x = 0; int t = 0; if (c == '-') t = 1, c = getchar_unlocked(); for (; (c < 48 || c>57); c = getchar_unlocked()); for (; c > 47 && c < 58; c = getchar_unlocked()) { x = (x << 1) + (x << 3) + c - 48; } if (t) x = -x; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int q; cin>>q; while(q--) { int n; cin>>n; set > s; int x1 = 100000, y1 = 100000, x2 = -1000000, y2 = -1000000; while(n--) { int x, y; cin>>x>>y; if(x < x1) x1 = x; if(y < y1) y1 = y; if(x > x2) x2 = x; if(y > y2) y2 = y; s.insert(pair(x, y)); } set >::iterator it; bool f = true; for(it = s.begin(); it != s.end(); it++) { if(!(((it->first >= x1 && it->first <= x2) && (it->second == y1 || it->second == y2)) || ((it->first == x1 || it->first == x2) && (it->second >= y1 && it->second <= y2)))) { f = false; break; } } if(f) cout<<"YES"<