import sys
T = int(input())
for _ in range(T):
st = []
s = input()
for ch in s:
if (len(st) != 0 and st[-1] != ch) or len(st) == 0:
st.append(ch)
elif ch == 'O':
st.pop()
elif ch == 'o':
st.pop()
if len(st) != 0:
st.pop()
else:
st.append('O')
print(''.join(st))

京公网安备 11010502036488号