#include <iostream>
#include <string>
using namespace std;

int main() {
    int T;
    cin>>T;
    string s;
    for (int i=0; i<T; i++) {
        cin>>s;
        // cout<<s;
        int lastlen=s.size();
        int len=s.size()-1;
        while (s.size()>2) {
            if (lastlen==len) {
                break;
            }
            lastlen=s.size();
            for (int i=0; i<s.size()-1; i++) {
                if (s[i]=='o'&&s[i+1]=='o') {
                    s.erase(s.begin()+i);
                    s[i]='O';
                    break;
                }
                else if (s[i]=='O'&&s[i+1]=='O') {
                    s.erase(s.begin()+i);
                    s.erase(s.begin()+i);
                    break;
                }
                // cout<<s;
            }
            len=s.size();
        }
        if (s[0]=='o'&&s[1]=='o') {
            s.erase(s.begin()+1);
            s[0]='O';            
        }
        else if (s[0]=='O'&&s[1]=='O') {
            s.clear();
        }
        cout<<s<<endl;
    }
}
// 64 位输出请用 printf("%lld")