#include using namespace std; const int N = 15; pair a[N]; int n; int main() { int q; cin >> q; while (q--) { cin >> n; for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second; pair topleft, botright; topleft = botright = a[0]; for (int i = 1; i < n; i++) { topleft.first = min(topleft.first, a[i].first); topleft.second = max(topleft.second, a[i].second); botright.first = max(botright.first, a[i].first); botright.second = min(botright.second, a[i].second); } bool k = true; for (int i = 0; i < n; i++) { if (a[i].first > botright.first || a[i].first < topleft.first) { cout << "NO" << endl; k = false; break; } if (a[i].second > topleft.second || a[i].second < botright.second) { cout << "NO" << endl; k = false; break; } if (a[i].first != topleft.first && a[i].first != botright.first && a[i].second != topleft.second && a[i].second != botright.second) { cout << "NO" << endl; k = false; break; } } if (k) cout << "YES" << endl; } }