for _ in range(int(input())):
    n = int(input())
    S = input()
    T = []
    for s in S[::-1]:
        if s == "B":
            T.append(s)
        elif len(T) >= 2 and T[-1] == "B" and T[-2] == "B":
            T.pop()
        else:
            T.append(s)
    print(*T[::-1], sep="")