#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
typedef pair<int,int> ii;
typedef pair<string,ii> P;
vector<P> output;
long long q;
string s;
int main(void){
    cin>>q;
    while(q--){
        cin>>s;
        long long ocnt=0;
        long long xcnt=0;
        for(int i=0;i<s.size();i++){
            if(s[i]=='o') ocnt++;
            else xcnt++;
        }
        if(xcnt>ocnt) cout<<-1<<endl;
        else if(xcnt==ocnt){
            bool ok=true;
            for(int i=0;i<s.size();i+=2){
                if(s[i]==s[i+1]){
                    cout<<-1<<endl;
                    ok=false;
                    break;
                }
            }
            if(ok){
                cout<<(s.size()/2)-1<<endl;
                for(int i=0;i<s.size()-1;i+=2){
                    cout<<"split "<<i<<" "<<1<<endl;
                }
            }
        }
        else{
            output.clear();
            long long number=0;
            long long ksize=1;
            while(s.size()>2){
                bool allo=true;
                for(int i=0;i<s.size();i++){
                    if(s[i]=='x')allo=false;
                }
                if(allo){
                    while(s.size()>2){
                        output.push_back(P("split",ii(number,1)));
                        number+=ksize+1;
                        ksize+=2;
                        s=s.substr(2);
                    }
                }
                else{
                    if(s[0]!=s[1]){
                        output.push_back(P("split",ii(number,1)));
                        number=ksize+1;
                        ksize+=2;
                        s=s.substr(2);
                    }
                    else if(s[s.size()-2]!=s[s.size()-1]){
                        output.push_back(P("split",ii(number,s.size()-3)));
                        number=ksize+1;
                        ksize+=2;
                        s=s.substr(0,s.size()-2);
                    }
                    else{
                        for(int i=1;i<s.size()-1;i++){
                            if(s[i]!=s[i+1]){
                                if(s[0]=='o'){
                                    int rot=0;
                                    for(int j=1;j<=i;j++){
                                        output.push_back(P("split",ii(number,j-rot)));
                                        output.push_back(P("join",ii(ksize+1,ksize)));
                                        number=number+2;
                                        ksize+=3;
                                        s=s.substr(j-rot+1)+s.substr(0,j-rot+1);
                                        rot=j+1;
                                    }
                                    output.push_back(P("split",ii(number,1)));
                                    s=s.substr(2);
                                    number=ksize+1;
                                    ksize+=2;
                                }
                                else{
                                    long long V=0;
                                    for(int j=i+2;j<s.size();j++){
                                        if(s[j]=='o')V++;
                                        else V--;
                                    }
                                    int t[110];
                                    for(int j=0;j<=s.size();j++)t[j]=-1;
                                    int dep=0;
                                    for(int j=s.size()-1;j>i+1;j--){
                                        if(s[j]=='o')dep++;
                                        else dep--;
                                        if(dep>=0)t[dep]=j;
                                    }
                                    int rot=0;
                                    for(int j=0;j<=V;j++){
                                        if(t[j]==-1)continue;
                                        output.push_back(P("split",ii(number,t[j]-1+rot)));
                                        output.push_back(P("join",ii(ksize+1,ksize)));
                                        number=ksize+2;
                                        ksize+=3;
                                        s=s.substr(t[j]+rot)+s.substr(0,t[j]+rot);
                                        rot=s.size()-t[j];
                                    }
                                    output.push_back(P("split",ii(number,s.size()-3)));
                                    s=s.substr(0,s.size()-2);
                                    number=ksize;
                                    ksize+=2;
                                }
                            }
                        }
                    }                
                }
            }
            cout<<output.size()<<endl;
            for(int i=0;i<output.size();i++){
                cout<<output[i].first<<" "<<output[i].second.first<<" "<<output[i].second.second<<endl;
            }
        }

    }
}

Measured memory_bytes: 3196