import sys input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) def solve(): n = ii() s = list(input()) while True: flag = True for i in range(len(s) - 2): if s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'B': s.pop(i) s.pop(i) flag = False break if flag: break print(''.join(s)) for _ in range(ii()): solve()