#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;

int main() {
    int t;
    cin >> t;
    stack<char> a;
    while (t--) {
        string s;
        cin >> s;
        for (int i = 0; i < s.length(); i++) {
            if (a.empty()) {
                a.push(s[i]);
                continue;
            }
            else if (a.top() == s[i] && s[i] == 'o') {
                a.pop();
                if(!a.empty() && a.top()=='O'){
                    a.pop();
                }
                else{
                    a.push('O');
                }
            } 
            else if (a.top() == s[i] && s[i] == 'O') {
                a.pop();
            }
            else{
                a.push(s[i]);
            }

        }
        
        string temp;
        while (!a.empty()) {
            temp.push_back(a.top());
            a.pop();
        }
        reverse(temp.begin(), temp.end());  // 反转后输出
        cout<<temp<<endl;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")