#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<string>
using namespace std;
char str[110];
struct wolf{
	int type;
	int num;
	int at;
	wolf(int a,int b,int c){
		type=a;num=b;at=c;
	}
	wolf(){type=num=at=0;}
};
int sz;
vector<wolf>v;
int t[210];
int main(){
	int a;scanf("%d",&a);
	while(a--){
		scanf("%s",str);
		int m=0;
		int b=0;
		int n=strlen(str);
		for(int i=0;str[i];i++){
			if(str[i]=='o')m++;
			else b++;
		}
		if(m<b){
			printf("-1\n");continue;
		}
		if(m==b){
			int now=0;
			bool ok=true;
			for(int i=0;str[i];i++){
				if(str[i]=='o')now++;
				else now--;
				if(now==2||now==-2)ok=false;
			}
			if(!ok){
				printf("-1\n");
			}else{
				printf("%d\n",n/2-1);
				for(int i=0;i<n/2-1;i++){
					printf("split %d %d\n",i*2,1);
				}
			}
			continue;
		}
		sz=1;
		v.clear();
		string now=str;
		int s=0;
		while(now.size()>2){
		//	printf("%s ",now.c_str());fflush(stdout);
			bool ow=true;
			for(int i=0;i<now.size();i++){
				if(now[i]=='x')ow=false;
			}
			if(ow){
				v.push_back(wolf(1,s,0));
				s=sz;
				sz++;
				now=now.substr(1);
				continue;
			}
			for(int i=0;i<now.size()-1;i++){
				if(now[i]=='o'&&now[i+1]=='o')continue;
				if(now[i]=='x'&&now[i+1]=='x')continue;
				int V=0;
				for(int j=0;j<i;j++){
					if(now[j]=='o')V++;
					else V--;
				}
				if(i==0){
					v.push_back(wolf(1,s,1));
					s=sz+1;
					sz+=2;
					now=now.substr(2);
					break;
				}
				if(i==now.size()-2){
					v.push_back(wolf(1,s,now.size()-3));
					s=sz;
					sz+=2;
					now=now.substr(0,now.size()-2);
					break;
				}
			//	printf("%d %d\n",i,V);fflush(stdout);
				if(V>=0){
					for(int j=0;j<110;j++)t[j]=-1;
					int dep=0;
					for(int j=0;j<i;j++){
						if(now[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;							
						v.push_back(wolf(1,s,t[j]-rot));
						v.push_back(wolf(2,sz+1,sz));
						s=sz+2;
						sz+=3;
						now=now.substr(t[j]-rot+1)+now.substr(0,t[j]-rot+1);
						rot=t[j]+1;
					}
					v.push_back(wolf(1,s,1));
					now=now.substr(2);
					s=sz+1;
					sz+=2;
				}else{
					V=0;
					for(int j=i+2;j<now.size();j++){
						if(now[j]=='o')V++;
						else V--;
					}
					for(int j=0;j<110;j++)t[j]=-1;
					int dep=0;
					for(int j=now.size()-1;j>i+1;j--){
						if(now[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;
					//	printf("%d %d %d\n",s,t[j],t[j]+rot);fflush(stdout);
						v.push_back(wolf(1,s,t[j]-1+rot));
						v.push_back(wolf(2,sz+1,sz));
						s=sz+2;
						sz+=3;
						now=now.substr(t[j]+rot)+now.substr(0,t[j]+rot);
						rot=now.size()-t[j];
					}
					v.push_back(wolf(1,s,now.size()-3));
					now=now.substr(0,now.size()-2);
					s=sz;
					sz+=2;
				}
				break;
			}
		}
		printf("%d\n",v.size());
		for(int i=0;i<v.size();i++){
			if(v[i].type==1)printf("split ");
			else printf("join ");
			printf("%d %d\n",v[i].num,v[i].at);
		}
	}
}