#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ int N; cin >> N; int needb = 1001001001,maxb = 0; bool ok = false; while(N--){ string s,t; cin >> s >> t; if(s == "a"){ int bs = 0; for(auto c : t) bs += c=='b'; if(bs == t.size()) maxb = max(maxb,(int)t.size()); else ok = true; } else{ int bs = 0; for(auto c : s) bs += c=='b'; if(bs == s.size()) needb = min(needb,(int)s.size()); } } if(maxb >= needb) ok = true; if(ok) cout << "Yes\n"; else cout << "No\n"; } }