#include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T;cin>>T; for(;T--;) { int N; string S; cin>>N>>S; const char flip='A'^'B'; if(N<=2); else { if(S[0]=='A') { if(S[1]=='A') { S[1]^=flip; for(int j=2;j