def solve(): n = int(input()) s = list(input()) stack = ['P', 'P'] for idx in reversed(range(n)): if s[idx] == 'B': stack.append(s[idx]) else: if stack[-1] != 'B': stack.append(s[idx]) elif stack[-2] == 'B': del stack[-1] else: stack.append(s[idx]) # print(stack) stack = stack[::-1] del(stack[-2:]) print(''.join(stack)) t = int(input()) for i in range(t): solve()