#include using namespace std; #define FOR(i,l,r) for(int i = (l);i < (r);i++) #define ALL(x) (x).begin(),(x).end() template void chmax(T& a,const T& b){if(a < b) a = b;} template void chmin(T& a,const T& b){if(b < a) a = b;} typedef long long ll; int Q; bool solve() { int N; cin >> N; vector< pair > coor(N); set x,y; FOR(i,0,N){ cin >> coor [i].first >> coor [i].second; x.insert(coor [i].first); y.insert(coor [i].second); } for(auto a : x){ for(auto b : x) if(a <= b){ for(auto c : y){ for(auto d : y) if(c <= d){ bool flag = true; FOR(i,0,N){ if((coor [i].first == a || coor [i].first == b) && (c <= coor [i].second && coor [i].second <= d)); else if((coor [i].second == c || coor [i].second == d) && (a <= coor [i].first && coor [i].first <= b)); else{ flag = false; break; } } if(flag){ return true; } } } } } return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> Q; FOR(i,0,Q){ cout << (solve() ? "YES" : "NO") << endl; } return 0; }