#include using namespace std; #define ll long long int main(){ int tc; cin >> tc; while(tc--){ map >mapper; int n; cin >> n; for(int i = 0 ; i < n ;i++){ int x , y; cin >> x >> y; mapper[x].insert(i); mapper[y].insert(i); } map >::iterator it; bool found = false; for(it = mapper.begin() ;!found && it!=mapper.end() ;it++){ if(it->second.size()==n) found = true; } if(found) cout << "YES"; else cout << "NO"; cout << endl; } }