#include using namespace std; typedef pair pii; const int MAX = 20; const int oo = 1e5; int q, n; pii cor[MAX]; pii bot_lef, top_rig; bool inRec(const pii& cor){ bool check = false; if (cor.first == bot_lef.first || cor.first == top_rig.first) check = check || (cor.second >= bot_lef.second && cor.second <= top_rig.second); if (cor.second == bot_lef.second || cor.second == top_rig.second) check = check || (cor.first >= bot_lef.first && cor.first <= top_rig.first); return check; } int main(){ //freopen("in.txt", "r", stdin); ios_base::sync_with_stdio(0); cin >> q; while (q--){ cin >> n; bot_lef = pii(oo, oo); top_rig = pii(-oo, -oo); for (int i = 0; i < n; ++i){ cin >> cor[i].first >> cor[i].second; bot_lef.first = min(bot_lef.first, cor[i].first); bot_lef.second = min(bot_lef.second, cor[i].second); top_rig.first = max(top_rig.first, cor[i].first); top_rig.second = max(top_rig.second, cor[i].second); } bool check = true; for (int i = 0; i < n; ++i) if (!inRec(cor[i])){ check = false; break; } cout << (check ? "YES\n" : "NO\n"); } return 0; }