import sys
N = int(input())

for _ in range(N):
    s = input()
    sta =list()
    for i in range(len(s)):
        #栈空直接放入
        if len(sta)==0:
            sta.append(s[i])
        #当s[i]=="o"并且栈顶为o时(先判断)
        elif s[i]=="o" and sta[len(sta)-1]=="o":
            #先将栈顶元素取出
            sta.pop()
            #判断一下,若取出后栈为空 或者取出后栈顶不为O,可以直接填入O,
            if len(sta)==0 or sta[len(sta)-1]!="O": 
                sta.append("O")     
            #否则则需再次取出栈顶元素,OO消失
            else:
                sta.pop()       
        #s[i]与栈顶同为O则消除(先判断,再消除)
        elif s[i]=="O" and sta[len(sta)-1]=="O":
            sta.pop()
            continue
        #其他情况直接入栈
        else:
            sta.append(s[i])
    print("".join(sta))