//a*b指的是一行b个元素
//DFS
//如果存在X则有1*12,否则为0,且1,2,3,4,5,6都不存在,如果有一个'O'则12*1不存在
//检验b=6时,对每一个ch[i]进行检验,判断ch[i]=='X'且ch[i+6]=='X',如果6不存在的话,2,3一定也不存在(但是代码上没写)
#include<iostream>
#include<cstring>
using namespace std;
int t,ok[6],tmp;
char ch[13];
int add[6]={12,6,4,3,2,1};
int dfs(int x,int add){
if(ch[x]!='X')
return 0;
if(x+add>12)
return 1;
return dfs(x+add,add);
}
int main (){
cin>>t;
while(t--){
cin>>ch;
memset(ok,0,sizeof(ok));
ok[5]=1;
for(int i=0;i<12;i++)//只要有一个不为X,则ok[5]=0
if(ch[i]!='X')
{
ok[5]=0;
break;
}
for(int i=0;i<12;i++)//只要有一个x
if(ch[i]=='X')
{
ok[0]=1;
break;
}
for(int i=1;i<5;i++)
{
for(int k=0;k<add[i];k++)
{
if(ch[k]!='X')
continue;
ok[i]=dfs(k+add[i],add[i]);
if(ok[i])
break;
}
}
int ans=0;
for(int i=0;i<6;i++)
if(ok[i])
ans++;
cout<<ans;
for(int i=0;i<6;i++)
if(ok[i])
cout<<" "<<12/add[i]<<"x"<<add[i];
cout<<endl;
}
return 0;
}