#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int T,si;string s[11];stack<char>S[11];stack<char>t[11];
int main(){
    cin>>T;
    for (int i=1; i<=T;++i) {
    cin>>s[i];
    for (char c:s[i]) {
    if (S[i].empty()) {
    S[i].push(c);
    }else {
    if (c=='o'&&S[i].top()=='o') {
    S[i].pop();
    if (S[i].empty()) {
    S[i].push('O');
    }else {
    if(S[i].top()=='O'){
        S[i].pop();
    }else{
        S[i].push('O');
    }
    }
    }else if (c=='O'&&S[i].top()=='O') {
    S[i].pop();
    }else {
    S[i].push(c);
    }
    }
    }
    si=S[i].size();
    if (si==0) {
    cout<<endl;
    }
    for (int j=1; j<=si;++j) {
    t[i].push(S[i].top());S[i].pop();
    }
    for (int j=1; j<=si;++j) {
    cout<<t[i].top();t[i].pop();
    if (j==si) {
    cout<<endl;
    }
    }
    }
    return 0;
}