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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */





//import com.sun.xml.internal.ws.util.StringUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;





/**
 *
 * @author george
 */

public class main {
    /*
public static boolean isPrime(long n) {
    if(n < 2) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    long sqrtN = (long)Math.sqrt(n)+1;
    for(long i = 6L; i <= sqrtN; i += 6) {
        if(n%(i-1) == 0 || n%(i+1) == 0) return false;
    }
    return true;
}*/
/*
    private static long f(long l) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

public static boolean contains(final int[] arr, final int key) {
    return Arrays.stream(arr).anyMatch(i -> i == key);
}
 static boolean isSubSequence(String str1, String str2, int m, int n)
    {
       
        if (m == 0) 
            return true;
        if (n == 0) 
            return false;
             
        
        if (str1.charAt(m-1) == str2.charAt(n-1))
            return isSubSequence(str1, str2, m-1, n-1);
 
        
        return isSubSequence(str1, str2, m, n-1);
    }

    static int gcdThing(int a, int b) {
    BigInteger b1 = BigInteger.valueOf(a);
    BigInteger b2 = BigInteger.valueOf(b);
    BigInteger gcd = b1.gcd(b2);
    return gcd.intValue();
}
    public static boolean checkAnagram(String str1, String str2) {
        int i=0;
        for (char c : str1.toCharArray()) {
        i = str2.indexOf(c, i) + 1;
        if (i <= 0) { return false; }
    }
    return true;

}
    
    public static Set primeFactors(int num)
    {
        Set<Integer>Prime=new HashSet<Integer>();
        // Print the number of 2s that divide n
        int tw=2;
        while (num%2==0)
        {
            Prime.add(tw);
            num /= 2;
        }
 
        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i <= Math.sqrt(num); i+= 2)
        {
            // While i divides n, print i and divide n
            while (num%i == 0)
            {
                Prime.add(i);
                num/= i;
            }
        }
 
        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (num> 2)
            Prime.add(num);        
        return Prime;
    }
    public static String Winner(int [] arr)
    {
        int maxsum=-1;
        int temp=0;
        List<Integer> L=Arrays.stream(arr).boxed().collect(Collectors.toList());
        int count=0;
        String winner="First";
        while(L.isEmpty()!=true){
           if(count%2==0){winner="First";
           //take max odd interval
            for (int i = 0; i < L.size(); i++) {
                
            }
            }
           else{winner="Second";
           
           
           
           
           
           
           
           }
           count++;
        }
    
    
    return winner;
    }
    public static String changeCharInPosition(int position, char ch, String str){
    char[] charArray = str.toCharArray();
    charArray[position] = ch;
    return new String(charArray);
    }
    public static boolean CheckCanObtainYfromX(String y,String x){
        boolean cond=true;
        String help="";
        for (int i = 0; i < y.length(); i++) {
            help="";help+=y.charAt(i);
            if(y.contains(help)==false){x=x.replaceFirst(help,"A");cond=false;break;}
            
        }
        return cond;
    }
   public static int LongestPalindrome(String x){
    int n=x.length();
    boolean table[][] = new boolean[n][n];
    int maxLength = 1;
     for (int i = 0; i < n; ++i)
            table[i][i] = true;
   int start = 0;
    for (int i = 0; i < n - 1; ++i) {
            if (x.charAt(i) == x.charAt(i + 1)) {
                table[i][i + 1] = true;
                start = i;
                maxLength = 2;
            }
        }
     for (int k = 3; k <= n; ++k) {
            for (int i = 0; i < n - k + 1; ++i) 
            {
                int j = i + k - 1;
               if (table[i + 1][j - 1] && x.charAt(i) == x.charAt(j)) {
                    table[i][j] = true;
                if (k > maxLength) {
                        start = i;
                        maxLength = k;
                    }
                }
            }
     }
   return maxLength;
   }
   public static long choose(long total, long choose){
    if(total < choose)
        return 0;
    if(choose == 0 || choose == total)
        return 1;
    return choose(total-1,choose-1)+choose(total-1,choose);
}
    public static long bitwiseAdd(int n1, int n2) {
        int x = n1, y = n2;
        int xor, and, temp;
        and = x & y;
        xor = x ^ y;

        while (and != 0) {
            and <<= 1;
            temp = xor ^ and;
            and &= xor;
            xor = temp;
        }
        return (xor%2);
    }
    public static boolean compare(String a,String b){
        for (int i = 0; i < a.length(); i++) {
            if(a.charAt(i)!=b.charAt(i)&&a.charAt(i)!='?'){return false;}
        }
  return true;
    }*/
/*public static boolean isUniqueChars(String str) {
    // short circuit - supposed to imply that
    // there are no more than 256 different characters.
    // this is broken, because in Java, char's are Unicode,
    // and 2-byte values so there are 32768 values
    // (or so - technically not all 32768 are valid chars)
    if (str.length() > 256) {
        return false;
    }
    // checker is used as a bitmap to indicate which characters
    // have been seen already
    int checker = 0;
    for (int i = 0; i < str.length(); i++) {
        // set val to be the difference between the char at i and 'a'
        // unicode 'a' is 97
        // if you have an upper-case letter e.g. 'A' you will get a
        // negative 'val' which is illegal
        int val = str.charAt(i) - 'a';
        // if this lowercase letter has been seen before, then
        // the corresponding bit in checker will have been set and
        // we can exit immediately.
        if ((checker & (1 << val)) > 0) return false;
        // set the bit to indicate we have now seen the letter.
        checker |= (1 << val);
    }
    // none of the characters has been seen more than once.
    return true;
}*/
 /*private static int [] PossibilitiesAsBinaryTruthTable(int n) {
        int rows = (int) Math.pow(2,n);
        int [] possibleTrack=new int[rows];
        int trackPerRow;
        for (int i=0; i<rows; i++) {
            trackPerRow=0;
            for (int j=n-1; j>=0; j--) {
                if(((i/(int) Math.pow(2, j))%2)==0){trackPerRow--;}
                else if(((i/(int) Math.pow(2, j))%2)==1){trackPerRow++;}
            }
            possibleTrack[i]=trackPerRow;
        }
        return possibleTrack;
    }*/
    public static void main (String []  args) throws IOException 
    {
        Scanner s=new Scanner(System.in);
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(new OutputStreamWriter(System.out));
        String line=br.readLine();
        int n=Integer.parseInt(line);
        String [] rows=new String[n];
        for (int i = 0; i < n; i++) {
            rows[i]=br.readLine();
        }
        // the possible mults are 2*6 3*4 1*12 and its reverses
        int ways=0;
        String result="";
        int checkrowEven=0;
        int checkrowOdd=0;
        for (int i = 0; i <n; i++) {
            if(rows[i].contains("X")==false){System.out.println(ways);continue;}
            if(rows[i].contains("O")==false){System.out.println("6 1x12 2x6 3x4 4x3 6x2 12x1");continue;}
            //check for all values 4*3 3*4 2*6 6*2
            //check for 2*6
            ways++;
            result+="1x12 ";
            for (int k=6, j = 0; j < 6; j++,k++) {
                if(rows[i].charAt(j)==rows[i].charAt(k)&&rows[i].charAt(j)=='X'){ways++;result+="2x6 ";break;}
            }
            //check for 3*4
            checkrowEven=0;checkrowOdd=0;
            for (int j = 0; j <=3; j++) {
                if(rows[i].charAt(j)==rows[i].charAt(j+4)&&rows[i].charAt(j+4)==rows[i].charAt(j+8)&&rows[i].charAt(j+4)=='X'){ways++;result+="3x4 ";break;}
            }
            //check for 4*3
            for (int j = 0; j <=2; j++) {
             if(rows[i].charAt(j)==rows[i].charAt(j+3)&&rows[i].charAt(j+3)==rows[i].charAt(j+6)&&rows[i].charAt(j+9)==rows[i].charAt(j+6)&&rows[i].charAt(j)=='X'){ways++;result+="4x3 ";break;}   
            }
            //check for 6*2
            for (int j = 0; j < 12; j++) {
                if(j%2==0){if(rows[i].charAt(j)=='X'){checkrowEven++;}}
                else{if(rows[i].charAt(j)=='X'){checkrowOdd++;}}
            }
            if(checkrowEven==6||checkrowOdd==6){ways++;result+="6x2 ";}
            System.out.print(ways);System.out.print(" ");System.out.println(result);
            ways=0;
            result="";
        }
    
    }  
   }