#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
std::string solve(std::string s) 
{
    std::stack<char> sta;

    for (char c : s) 
    {
        sta.push(c);
        while (sta.size() >= 2) 
        {
            char top1 = sta.top(); sta.pop();
            char top2 = sta.top(); sta.pop();

            if (top1 == 'o' && top2 == 'o') 
            {
                sta.push('O');
            }
            else if (top1 == 'O' && top2 == 'O') 
            {
            }
            else 
            {
                sta.push(top2);
                sta.push(top1);
                break;
            }
        }
    }
    std::string result;
    while (!sta.empty()) 
    {
        result += sta.top();
        sta.pop();
    }
    std::reverse(result.begin(), result.end());
    return result;
}
int main() 
{
    int T;
    std::cin >> T;

    while (T--) 
    {
        std::string s;
        std::cin >> s;
        std::cout << solve(s) << std::endl;
    }

    return 0;
}