#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        stack<char> sta;
        for(auto c:s)
        {
            if(sta.empty()) sta.push(c);
            else {
                if(!sta.empty()&&sta.top()=='o'&&c=='o')
                {
                    sta.pop();
                    if(!sta.empty()&&sta.top()=='O') sta.pop();
                    else sta.push('O');
                    
                }
                else if(!sta.empty()&&sta.top()=='O'&&c=='O')
                {
                    sta.pop();
                }
                else sta.push(c);
            }
        }
        string str;
        while(!sta.empty())
        {
            str+=sta.top();
            sta.pop();
        }
        for(int i=(int)str.length()-1;i>=0;i--)
        {
            cout<<str[i];
        }
        cout<<endl;
    }
    return 0;
}