#include using namespace std; #define ll long long const ll maxn=250005; char s[maxn+5]; bool v1[15],v2[15],h[5]; vector st,cur,nx; int main(){ ll t,n,i,j,k,ans,p,f,nf,np,ch,mn; bool fd; scanf("%lld",&t); while(t--){ scanf("%lld",&n); scanf("%s",s+1); for(i=0;i<12;i++) v1[i]=0; v1[0]=1,ans=-1; for(i=1;i<=n;i++){ for(j=0;j<12;j++) v2[j]=0; fd=0,st.clear(); for(j=0;j<12;j++){ if(not v1[j]) continue; p=j/3,f=j%3; for(nf=f;nf<=(f==1?2:(f==0?1:2));nf++){ if(f==2 and nf!=2) continue; ch=(s[i]=='A'?0:1); if(nf==1) ch^=1; np=p; if(p==0) np=(ch==1?1:2); else if(p==1) np=(ch==1?1:2); else if(p==2) np=(ch==0?2:3); else if(p==3) np=(ch==1?3:4); if(np==4) fd=1,st.push_back(nf); else v2[np*3+nf]=1; } } if(fd){ ans=i; break; } for(j=0;j<12;j++) v1[j]=v2[j]; } if(ans==-1){ for(i=1;i<=n;i++) printf("B"); printf("\n"); } else{ for(i=1;i