T=int(input()) Ans=[""]*T for t in range(T): N=int(input()) S=input() Q=[] for x in S: Q.append(x) while True: if len(Q)>=3 and Q[-3]=="A" and Q[-2]=="B" and Q[-1]=="B": Q.pop() Q.pop() Q.pop() Q.append("B") else: break Ans[t]="".join(Q) print(*Ans,sep="\n")