Problem: There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below:

There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (a·b = 12), after that he makes a table of size a × b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses.

Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win.

Input

The first line of the input contains integer t (1 ≤ t ≤ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line.

The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start.

Output

For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces.

Examples

Input

4
OXXXOXOOXOOX
OXOXOXOXOXOX
XXXXXXXXXXXX
OOOOOOOOOOOO


Output

3 1x12 2x6 4x3
4 1x12 2x6 3x4 6x2
6 1x12 2x6 3x4 4x3 6x2 12x1
0

Solution (in JAVA):

Solution:
//package Codeforces;

//package Codeforces;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.ArrayList;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;
import java.util.PriorityQueue;
import java.util.HashMap;
import java.util.Stack;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.TreeSet;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.BitSet;
import java.util.Random;
import java.util.ArrayDeque;
import java.math.*;
import java.util.List;
import java.util.Iterator;
import java.io.*;
import java.util.*;
public class SPOJBABTWR{
    final static boolean DEBUG=false;
    static InputStream inputStream ;
    static OutputStream outputStream ;
    static InputReader in ;
    static OutputWriter outt ;
    static FileInputStream fstream ;;
    static DataInputStream in1;
    static BufferedReader x1 ;
    static FileOutputStream out ;
    String newLine="\n";
    int dp[][];
        public static void main(String []args)throws IOException{
        if(!DEBUG){
            inputStream = System.in;
            outputStream = System.out;
            in = new InputReader(inputStream);
            outt = new OutputWriter(outputStream);
           // x1=new BufferedReader(new InputStreamReader(System.in));
        }
        else{
            fstream = new FileInputStream("input.txt");
            in1 = new DataInputStream(fstream);
            x1 = new BufferedReader(new InputStreamReader(in1));
            out = new FileOutputStream(new File("output.txt"));
        }
        SPOJBABTWR Solver=new SPOJBABTWR();
        int T=1;
        if(!DEBUG)
           T=in.readInt();
        //else
          //  T=Integer.parseInt(x1.readLine()); 
        while(T-->0)
            Solver.solve();
            if(!DEBUG)
            outt.close();
        else 
            out.close();
            
 }
 public void solve()throws IOException{
          char s[]=in.readString().toCharArray();
          ArrayList<String> arr=new ArrayList<String>();
          
          if(check(1,12,s))
            arr.add("1x12");
           if(check(2,6,s))
            arr.add("2x6");
           if(check(3,4,s))
            arr.add("3x4");
           if(check(4,3,s))
            arr.add("4x3");
           if(check(6,2,s))
            arr.add("6x2");
           if(check(12,1,s))
            arr.add("12x1");
          outt.print(arr.size()+" ");
          for(int i=0;i<arr.size();i++)
            outt.print(arr.get(i)+" ");
            outt.printLine();
            
        }
        boolean check(int N,int M,char[]s){
        //  System.out.println(N+" "+M);
            char c[][]=new char[N][M];
            for(int i=0;i<N;i++){
                for(int j=0;j<M;j++){
                //  System.out.println(i*M+j);
                    c[i][j]=s[i*M+j];
                }
            }
            boolean good=false;
            for(int i=0;i<M;i++){
                boolean here=true;
                for(int j=0;j<N;j++)
                    if(c[j][i]!='X')
                        here=false;
                        good=good|here;
            }
            return good;
        
        }
        
         static long pow(long n, long exp,long mod){
            long prod = 1;
            while (exp > 0){
                if ((exp & 1) != 0){
                    prod *= n;
                    if(prod>=mod)
                    prod=prod%mod;
                }
                n*=n;
                if(n>=mod)
                n=n%mod;
                exp >>= 1;
            }
            return prod;
 }
       
    }
class Box implements Comparable<Box>{
    int a,b,c,h;//m;
    Box(int aa,int bb,int cc){
        a=aa;b=bb;c=cc;
    }
    @Override
    public int compareTo(Box A){
        return this.a-A.a;
    }
}
class InputReader {
    
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;
 
    public InputReader(InputStream stream) {
        this.stream = stream;
    }
 
    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }
 
    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
 
    public String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
 
    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
 
    public String next() {
        return readString();
    }
 
    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}
 
class OutputWriter {
    private final PrintWriter writer;
 
    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }
 
    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }
 
    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }
 
    public void printLine(Object...objects) {
        print(objects);
        writer.println();
    }
 
    public void close() {
        writer.close();
    }}