#include using namespace std; #define REP(i,n) for(int i=0;i P; typedef pair PP; typedef pair Q; typedef pair QQ; ll par[200010],rk[200010],sz[200010]; void init(ll n){ REP(i,n+1){ par[i]=i; rk[i]=0; sz[i]=1; } } ll find(ll x){ if(par[x]==x){ return x; }else{ return par[x]=find(par[x]); } } void unite(ll x,ll y){ x=find(x); y=find(y); if(x==y) return; if(rk[x]> T; REP(tc,T){ ll N; cin >> N; vector q; vector qq; REP(i,N){ char c; ll x; cin >> c >> x; q.push_back(Q(P(c,x),i+1)); qq.push_back(QQ(PP(x,c),i+1)); } sort(q.begin(),q.end()); sort(qq.begin(),qq.end()); init(N); REP(i,N-1) if(q[i].first.first==q[i+1].first.first) unite(q[i].second,q[i+1].second); REP(i,N-1) if(qq[i].first.first==qq[i+1].first.first) unite(qq[i].second,qq[i+1].second); if(size(1)==N) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }