#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
 int m;
 cin>>m;
 while(m--){
  while(cin>>s){
    stack<char> st;
     int n=s.length();
    if(n==1) cout<<s;
    else{
      for(int i=0;i<n;i++){
        if(st.empty()){
          st.push(s[i]);
        }
        else{
          if(s[i]==st.top()){
            if(s[i]=='o'){
              st.pop();
              if(st.empty()){
                st.push('O');
              }
            else {
                if(st.top()=='O'){
                  st.pop();
                }
                else{
                  st.push('O');
                }
              }
            }
            else{
              st.pop();
            }
          }
          else st.push(s[i]);
        }
      }
      stack<char>st1;
      while(!st.empty()){
        st1.push(st.top());
        st.pop();
      }
      while(!st1.empty()){
        cout<<st1.top();
        st1.pop();
      }
    }
      cout<<endl;
  }

 }
    return 0;
}