import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.BitSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Omar-Handouk
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {

            int n = in.nextInt();

            int[] a = new int[]{
                    1, 2, 3, 4, 6, 12
            };

            int[] b = new int[]{
                    12, 6, 4, 3, 2, 1
            };

            while (n-- > 0) {
                char[] seq = in.readLine().toCharArray();

                BitSet valid = new BitSet();
                boolean[] isValid = new boolean[6];

                for (int i = 0; i < 6; ++i) {
                    inner:
                    for (int j = 0; j < 12; ++j) {

                        int idx = j;
                        if (seq[j] == 'O')
                            continue;

                        int occ = 1;
                        while (idx < 12) {
                            if (occ == a[i])
                                break;
                            idx = idx + b[i];
                            if (idx < 12 && seq[idx] == 'X')
                                ++occ;
                            else
                                continue inner;
                        }

                        if (occ == a[i]) {
                            isValid[i] = true;
                            valid.set(i);
                            break;
                        }
                    }
                }

                out.print(valid.cardinality() + " ");

                for (int i = 0; i < 6; ++i)
                    out.print(isValid[i] ? a[i] + "x" + b[i] + " " : "");
                out.println();
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.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 nextInt() {
            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 boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private String readLine0() {
            StringBuilder buf = new StringBuilder();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r') {
                    buf.appendCodePoint(c);
                }
                c = read();
            }
            return buf.toString();
        }

        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0) {
                s = readLine0();
            }
            return s;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static 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 println() {
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Omar-Handouk
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, OutputWriter out) {

            int[] a = {1, 2, 3, 4, 6, 12};
            int[] b = {12, 6, 4, 3, 2, 1};

            int n = in.nextInt();

            while (n-- > 0) {
                char[] word = in.nextCharArray();

                StringBuilder ans = new StringBuilder();
                int ways = 0;

                for (int i = 0; i < 6; ++i) {
                    if (check(word, a[i], b[i])) {
                        ++ways;
                        ans.append(" " + a[i] + "x" + b[i]);
                    }
                }

                out.println(ways + " " + ans);
            }
        }

        boolean check(char[] word, int a, int b) {
            char[][] grid = new char[a][b];

            int k = 0;

            for (int i = 0; i < a; ++i) {
                for (int j = 0; j < b; ++j) {
                    grid[i][j] = word[k++];
                }
            }

            boolean can = false;
            outer:
            for (int j = 0; j < b; ++j) {
                for (int i = 0; i < a; ++i) {
                    if (grid[i][j] == 'O')
                        continue outer;
                }

                can = true;
            }

            return can;
        }

    }

    static 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 println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class Scanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        public Scanner(InputStream stream) {
            bufferedReader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            String string = "";

            try {
                string = bufferedReader.readLine();
            } catch (IOException Error) {
                Error.printStackTrace();
            }

            return string;
        }

        public String next() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException Error) {
                    Error.printStackTrace();
                    ;
                }
            }

            return stringTokenizer.nextToken();
        }

        public char[] nextCharArray() {
            char[] charArray = this.nextLine().toCharArray();

            return charArray;
        }

        public int nextInt() {
            int number = Integer.parseInt(this.next());

            return number;
        }

    }
}


import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int t = sc.nextInt();
		for (int tc = 0; tc < t; tc++) {
			String cards = sc.next();

			System.out.println(solve(cards));
		}

		sc.close();
	}

	static String solve(String cards) {
		int[] rows = IntStream.rangeClosed(1, 12).filter(a -> {
			if (12 % a != 0) {
				return false;
			}

			int b = 12 / a;

			return IntStream.range(0, b)
					.anyMatch(c -> IntStream.range(0, a).allMatch(r -> cards.charAt(r * b + c) == 'X'));
		}).toArray();

		return String.format("%d %s", rows.length, Arrays.stream(rows)
				.mapToObj(row -> String.format("%dx%d", row, 12 / row)).collect(Collectors.joining(" ")));
	}
}


import java.util.Scanner;
public class Ishu
{
	public static void main(String []args)
	{
	Scanner scan=new Scanner(System.in);
	int t,i,ans=0,k;
	boolean flag=true;
	String str;
	int[]factor=new int[6];
	factor[0]=12;
	factor[1]=6;
	factor[2]=4;
	factor[3]=3;
	factor[4]=2;
	factor[5]=1;
	int[][] a=new int[6][2];
	t=scan.nextInt();
	while(t-->0)
		{
		str=scan.next();
		k=0;
		ans=0;
		while(k<6)
			{
			for(i=0;i<factor[k];++i)
				{
				flag=true;
				for(int j=i;j<12;j=j+factor[k])
					if(str.charAt(j)!='X')
						{
						flag=false;
						break;
						}
				if(flag)
					break;
				}
			if(i<factor[k])
				{
				a[ans][0]=12/factor[k];
				a[ans++][1]=factor[k];
				}
			k++;
			}
		System.out.print(ans);
		for(i=0;i<ans;++i)
			System.out.print("\t"+a[i][0]+"x"+a[i][1]);
		System.out.println();
		}
	}
}


import java.io.*;
import java.util.*;

public class Solution {
    void solve() throws IOException {
        int t = in.nextInt();
        int[] divisors = {1, 2, 3, 4, 6, 12};

        StringBuilder sb = new StringBuilder(t * divisors.length * 2);
        for (int i = 0; i < t; i++) {
            char[] cards = in.next().toCharArray();
            List<Integer> ans = new ArrayList<>(divisors.length);

            for (int d : divisors) {
                boolean dRow = false;

                for (int j = 0; j < 12 / d; j++) {
                    boolean curRow = true;
                    for (int k = j; k < 12; k += d) {
                        curRow &= cards[k] == 'X';
                    }
                    dRow |= curRow;
                }

                if (dRow) ans.add(d);
            }

            sb.append(ans.size()).append(' ');
            for (Integer d : ans) {
                sb.append(d).append('x').append(12 / d).append(' ');
            }
            sb.append('\n');
        }
        System.out.println(sb.toString());
    }

    public void run() throws IOException {
        in = new MyScanner();
        solve();
        in.close();
    }

    private MyScanner in;

    public class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() {
            this.br = new BufferedReader(new InputStreamReader(System.in));
        }

        public MyScanner(String fileTitle) throws IOException {
            this.br = new BufferedReader(new FileReader(fileTitle + ".in"));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return "-1";
                }
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public int[] nextIntArr(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        public void close() throws IOException {
            br.close();
        }
    }

    public static void main(String[] args) throws IOException {
        new Solution().run();
    }
}


import java.io.*;
import java.util.*;

public class Solution {
    void solve() throws IOException {
        int t = in.nextInt();
        int[] divisors = {1, 2, 3, 4, 6, 12};

        StringBuilder sb = new StringBuilder(t * divisors.length * 2);
        for (int i = 0; i < t; i++) {
            char[] cards = in.next().toCharArray();
            List<Integer> ans = new ArrayList<>(divisors.length);

            for (int d : divisors) {
                boolean dRow = false;

                for (int j = 0; j < 12 / d; j++) {
                    boolean curRow = true;
                    for (int k = j; k < 12; k += 12 / d) {
                        curRow &= cards[k] == 'X';
                    }
                    dRow |= curRow;
                }

                if (dRow) ans.add(d);
            }

            sb.append(ans.size()).append(' ');
            for (Integer d : ans) {
                sb.append(d).append('x').append(12 / d).append(' ');
            }
            sb.append('\n');
        }
        System.out.println(sb.toString());
    }

    public void run() throws IOException {
        in = new MyScanner();
        solve();
        in.close();
    }

    private MyScanner in;

    public class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() {
            this.br = new BufferedReader(new InputStreamReader(System.in));
        }

        public MyScanner(String fileTitle) throws IOException {
            this.br = new BufferedReader(new FileReader(fileTitle + ".in"));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return "-1";
                }
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public int[] nextIntArr(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        public void close() throws IOException {
            br.close();
        }
    }

    public static void main(String[] args) throws IOException {
        new Solution().run();
    }
}


import java.util.*;

import javax.sound.sampled.ReverbType;

import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class m {

	public static void main(String[] args) throws IOException, InterruptedException {
		PrintWriter pw = new PrintWriter(System.out);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		for (int m = 0; m < n; m++) {
			int[] l1 = { 1, 2, 3, 4, 6, 12 };
			int[] l2 = { 12, 6, 4, 3, 2, 1 };
			int c = 0;
			String s = br.readLine();
			String r = "";
			for (int i = 0; i < 6; i++) {
				String[][] l = new String[l1[i]][l2[i]];

				int numbers = 0;
				for (int j = 0; j < l1[i]; j++) {
					for (int k = 0; k < l2[i]; k++) {
						l[j][k] = "" + s.charAt(numbers++);
					}
				}
				//System.out.println(Arrays.deepToString(l));

				for (int j = 0; j < l2[i]; j++) {
					boolean f = true;
					for (int k = 0; k < l1[i]; k++) {
						if (!l[k][j].equals("X") ) {
							f = false;
							break;
						}
					}
					if (f) {
						c++;
						r = r + " " + l1[i] + "x" + l2[i];
						break;
					}
				}
			}
			pw.println(c+r);
		}

		pw.flush();
		pw.close();
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF_400_A_INNA_AND_CHOOSE_OPTIONS {

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		String [] ans = {"1x12","2x6","3x4","4x3","6x2","12x1" };
		StringBuilder st = new StringBuilder();
		while(t-->0)
		{

			boolean [] vis = new boolean[6];

			char[]c = sc.next().toCharArray();
			int x = 0;
			for(char ch :c)
				if(ch == 'X')
					x++;

			if(x > 0)
				vis[0] = true ;
			if(x == 12)
				vis[5] = true ;

			for(int i = 0  ; i+6< 12 ;i++)
				if(c[i] == 'X' && c[i+6] == 'X')
					vis[1] = true;

			for(int i = 0  ; i+6< 12 ;i++)
				if(c[i] == 'X' && c[i+2] == 'X' && c[i+4] == 'X' && c[i+6] == 'X')
					vis[4] = true;

			for(int i = 0  ; i+9 < 12  ; i++)
				if(c[i] == 'X' && c[i+3] == 'X' && c[i+6] == 'X' && c[i+9] =='X')
					vis[2] = true;

			for(int i = 0  ; i+8 < 12  ; i++)
				if(c[i] == 'X' && c[i+4] == 'X' && c[i+8] == 'X')
					vis[3] = true;

			/////////////-----------------------------------------

			int res = 0 ;

			for(boolean b : vis)
				if(b)
					res++;

			st.append(res).append(" ");

			for(int i = 0 ;i< 6 ; i++)
				if(vis[i])
					st.append(ans[i]).append(" ");

			st.append("\n");
		}

		System.out.print(st);

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream fileReader) {
			br = new BufferedReader(new InputStreamReader(fileReader));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF_400_A_INNA_AND_CHOOSE_OPTIONS {

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		String [] ans = {"1x12","2x6","3x4","4x3","6x2","12x1" };
		StringBuilder st = new StringBuilder();
		while(t-->0)
		{

			boolean [] vis = new boolean[6];

			char[]c = sc.next().toCharArray();
			int x = 0;
			for(char ch :c)
				if(ch == 'X')
					x++;

			if(x > 0)
				vis[0] = true ;
			if(x == 12)
				vis[5] = true ;

			for(int i = 0  ; i+6< 12 ;i++)
				if(c[i] == 'X' && c[i+6] == 'X')
					vis[1] = true;

			for(int i = 0  ; i+10< 12 ;i++)
				if(c[i] == 'X' && c[i+2] == 'X' && c[i+4] == 'X' && c[i+6] == 'X' && c[i+8] == 'X' && c[i+10] == 'X')
					vis[4] = true;

			for(int i = 0  ; i+9 < 12  ; i++)
				if(c[i] == 'X' && c[i+3] == 'X' && c[i+6] == 'X' && c[i+9] =='X')
					vis[3] = true;

			for(int i = 0  ; i+8 < 12  ; i++)
				if(c[i] == 'X' && c[i+4] == 'X' && c[i+8] == 'X')
					vis[2] = true;

			/////////////-----------------------------------------

			int res = 0 ;

			for(boolean b : vis)
				if(b)
					res++;

			st.append(res).append(" ");

			for(int i = 0 ;i< 6 ; i++)
				if(vis[i])
					st.append(ans[i]).append(" ");

			st.append("\n");
		}

		System.out.print(st);

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream fileReader) {
			br = new BufferedReader(new InputStreamReader(fileReader));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF_400_A_INNA_AND_CHOOSE_OPTIONS {

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		String [] ans = {"1x12","2x6","3x4","4x3","6x2","12x1" };
		StringBuilder st = new StringBuilder();
		while(t-->0)
		{

			boolean [] vis = new boolean[6];

			char[]c = sc.next().toCharArray();
			int x = 0;
			for(char ch :c)
				if(ch == 'X')
					x++;

			if(x > 0)
				vis[0] = true ;
			if(x == 12)
				vis[5] = true ;

			for(int i = 0  ; i+6< 12 ;i++)
				if(c[i] == 'X' && c[i+6] == 'X')
					vis[1] = true;

			for(int i = 0  ; i+6< 12 ;i++)
				if(c[i] == 'X' && c[i+2] == 'X' && c[i+4] == 'X' && c[i+6] == 'X')
					vis[4] = true;

			for(int i = 0  ; i+9 < 12  ; i++)
				if(c[i] == 'X' && c[i+3] == 'X' && c[i+6] == 'X' && c[i+9] =='X')
					vis[3] = true;

			for(int i = 0  ; i+8 < 12  ; i++)
				if(c[i] == 'X' && c[i+4] == 'X' && c[i+8] == 'X')
					vis[2] = true;

			/////////////-----------------------------------------

			int res = 0 ;

			for(boolean b : vis)
				if(b)
					res++;

			st.append(res).append(" ");

			for(int i = 0 ;i< 6 ; i++)
				if(vis[i])
					st.append(ans[i]).append(" ");

			st.append("\n");
		}

		System.out.print(st);

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream fileReader) {
			br = new BufferedReader(new InputStreamReader(fileReader));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF_400_A_INNA_AND_CHOOSE_OPTIONS {

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		String [] ans = {"1x12","2x6","3x4","4x3","6x2","12x1" };
		StringBuilder st = new StringBuilder();
		while(t-->0)
		{

			boolean [] vis = new boolean[6];

			char[]c = sc.next().toCharArray();

			if(c[11] == 'X')
				vis[0] = true ;

			vis[5] = true ;
			for(char ch : c)
				if(ch != 'X')
					vis[5] = false;

			vis[4] = true ;
			for(int i = 1 ; i<12 ; i+=2)
				if(c[i] != 'X')
					vis[4] = false;

			if(c[5] == 'X' && c[11] == 'X')
				vis[1] = true;

			vis[3] = true;

			for(int i = 2 ; i<12 ; i+=3)
				if(c[i] != 'X')
					vis[3] = false;

			vis[2] = true;
			for(int i = 3 ; i< 12 ;i+=4)
				if(c[i] != 'X')
					vis[2] = false;

			int res = 0 ;

			for(boolean b : vis)
				if(b)
					res++;

			st.append(res).append(" ");

			for(int i = 0 ;i< 6 ; i++)
				if(vis[i])
					st.append(ans[i]).append(" ");

			st.append("\n");
		}

		System.out.print(st);

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream fileReader) {
			br = new BufferedReader(new InputStreamReader(fileReader));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF_400_A_INNA_AND_CHOOSE_OPTIONS {

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		String [] ans = {"1x12","2x6","3x4","4x3","6x2","12x1" };
		StringBuilder st = new StringBuilder();
		while(t-->0)
		{

			boolean [] vis = new boolean[6];

			char[]c = sc.next().toCharArray();

			if(c[5] == 'X')
				vis[0] = true ;

			vis[5] = true ;
			for(char ch : c)
				if(ch != 'X')
					vis[5] = false;

			vis[4] = true ;
			for(int i = 1 ; i<12 ; i+=2)
				if(c[i] != 'X')
					vis[4] = false;

			if(c[5] == 'X' && c[11] == 'X')
				vis[1] = true;

			vis[3] = true;

			for(int i = 2 ; i<12 ; i+=3)
				if(c[i] != 'X')
					vis[3] = false;

			vis[2] = true;
			for(int i = 3 ; i< 12 ;i+=4)
				if(c[i] != 'X')
					vis[2] = false;

			int res = 0 ;

			for(boolean b : vis)
				if(b)
					res++;

			st.append(res).append(" ");

			for(int i = 0 ;i< 6 ; i++)
				if(vis[i])
					st.append(ans[i]).append(" ");

			st.append("\n");
		}

		System.out.print(st);

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream fileReader) {
			br = new BufferedReader(new InputStreamReader(fileReader));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


import java.util.*;
import java.io.*;
public class A{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for(int tCounter = 0; tCounter < t; tCounter++) {
			String stringEnter = sc.next();
			String stringFinal = "";

			TreeSet<Integer> tree = new TreeSet<>();

			int sum = 0;

			for(int counter = 1; counter <= 12; counter++) {
				if(12 % counter != 0)
					continue;
				for(int innerCounter = 0; innerCounter < counter; innerCounter++) {
					boolean flag = true;
					for(int anotherCoutner = innerCounter; anotherCoutner < 12; anotherCoutner += counter) {
						if(stringEnter.charAt(anotherCoutner) != 'X') {
							flag = false;
							break;
						}
					}
					if(flag) {
						int put = 12 / counter;
						if(!tree.contains(put)) {
							sum++;
							tree.add(put);
						}
					}
				}
			}

			if(tree.size() == 0)
				System.out.print(0);
			else {
				System.out.print(sum);
				while(!tree.isEmpty()) {
					int out = tree.pollFirst();
					System.out.print(" " + out + "x" + 12 / out);
				}
			}

			System.out.print("\n");
		}
	}
}


import java.util.*;
import java.io.*;
public class A{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for(int tCounter = 0; tCounter < t; tCounter++) {
			String stringEnter = sc.next();
			String stringFinal = "";

			ArrayList<String> array = new ArrayList<>();

			int sum = 0;

			for(int counter = 12; counter >= 1; counter--) {
				if(12 % counter != 0)
					continue;
				for(int innerCounter = 0; innerCounter < counter; innerCounter++) {
					boolean flag = true;
					for(int anotherCoutner = innerCounter; anotherCoutner < 12; anotherCoutner += counter) {
						if(stringEnter.charAt(anotherCoutner) != 'X') {
							flag = false;
							break;
						}
					}
					if(flag) {
						String put = " " +  12 / counter + "x" + counter;
						if(!array.contains(put)) {
							sum++;
							array.add(put);
						}
					}
				}
			}

			if(array.size() == 0)
				System.out.print(0);
			else {
				System.out.print(sum);
				for(int counter = 0; counter < array.size(); counter++) {
					System.out.print(array.get(counter));
				}
			}

			System.out.print("\n");
		}
	}
}


import java.util.Scanner;

/*
 * 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.
 */

/**
 *
 * @author workzone
 */
public class cards_game {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        String str;
        sc.nextLine();
        char a1[][]=new char[1][12];
        char a2[][]=new char[2][6];
        char a3[][]=new char[3][4];
        for(int test=0;test<t;++test)
        {
            str=sc.nextLine();
            for(int i=0;i<12;++i)
            {
                a1[0][i]=str.charAt(i);
            }
            int index=0;
            for(int i=0;i<2;++i)
            {
                for(int j=0;j<6;++j)
                {
                    a2[i][j]=str.charAt(index);
                    ++index;
                }
            }
            index=0;
            for(int i=0;i<3;++i)
            {
                for(int j=0;j<4;++j)
                {
                    a3[i][j]=str.charAt(index);
                    ++index;
                }
            }
            int chk1=0,chk2=0,chk3=0;
            for(int i=0;i<12;++i)
            {
                if(a1[0][i]=='X')
                {
                    chk1=1;
                }
            }
            int count=0;
            for(int j=0;j<6;++j)
            {
                count=0;

                for(int i=0;i<2;++i)
                {
                    if(a2[i][j]=='X')
                    {
                        count++;
                    }
                }
                if(count==2)
                {
                    chk2=1;
                }
            }
            for(int j=0;j<4;++j)
            {
                count=0;

                for(int i=0;i<3;++i)
                {
                    if(a3[i][j]=='X')
                    {
                        count++;
                    }
                }
                if(count==3)
                {
                    chk3=1;
                }
            }
            System.out.print(chk1+chk2+chk3+" ");
            if(chk1==1)
            {
                System.out.print("1x12 ");
            }
            if(chk2==1)
            {
                System.out.print("2x6 ");
            }
            if(chk3==1)
            {
                System.out.print("3x4 ");
            }
            System.out.println();

        }
    }
}


import java.util.Scanner;

/*
 * 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.
 */

/**
 *
 * @author workzone
 */
public class grid_0X {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        sc.nextLine();
        for(int test=0;test<t;++test)
        {
            String str;
            str=sc.nextLine();
            int ar[]=new int[12];
            for(int i=0;i<12;++i)
            {
                if(str.charAt(i)=='O')
                {
                    ar[i]=0;
                }
                else
                {
                    ar[i]=1;
                }
            }
            int br[]={1,2,3,4,6,12};
            int cr[]=new int[6];
            for(int i=0;i<6;++i)
            {
                cr[i]=0;
            }
            for(int i=0;i<6;++i)
            {
                int num=br[i];
                for(int j=0;j<12/num;++j)
                {
                    int count=0;
                    for(int k=j;k<12;k+=12/num)
                    {
                        if(ar[k]==1)
                        {
                            count++;
                        }
                    }
                    if(count==num)
                    {
                        cr[i]=1;
                    }
                }
            }
            int count=0;
            for(int i=0;i<6;++i)
            {
                if(cr[i]==1)
                {
                    count++;
                }
            }
            System.out.print(count+" ");
            for(int i=0;i<6;++i)
            {
                if(cr[i]==1)
                {
                    System.out.print(br[i]+"x"+12/br[i]+" ");
                }
            }
            System.out.println();
        }
    }

}


import java.util.ArrayList;
import java.util.Scanner;

/*
 * 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.
 */

/**
 *
 * @author workzone
 */
public class cards_game {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        String str;
        sc.nextLine();
        char ar[]=new char[12];
        int br[]=new int[6];
        br[0]=1;
        br[1]=2;
        br[2]=3;
        br[3]=4;
        br[4]=6;
        br[5]=12;
        int count;
        int cr[]=new int[6];
        for(int test=0;test<t;++test)
        {
            for(int i=0;i<6;++i)
            {
                cr[i]=0;
            }
            str=sc.nextLine();
            for(int i=0;i<12;++i)
            {
                ar[i]=str.charAt(i);
               // System.out.print(ar[i]);
            }
            for(int i=0;i<6;++i)
            {
                int num=br[i];
                for(int j=0;j<num;j++)
                {
                    count=0;
                    int inc=12/num;
                    for(int k=j;k<12;k+=inc)
                    {
                        if(ar[k]=='X')
                        {
                            count++;
                        }
                    }
                    if(count==num)
                    {
                        cr[i]=1;
                    }
                }
            }
            count=0;
            for(int i=0;i<6;++i)
            {
                if(cr[i]==1)
                {
                    count++;
                }
            }
            System.out.print(count+" ");
            for(int i=0;i<6;++i)
            {
                if(cr[i]==1)
                {
                    System.out.print(br[i]+"x"+12/br[i]+" ");
                }
            }
            System.out.println();
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.util.StringTokenizer;
import java.io.InputStreamReader;
public class Solution {
    public static void main(String []args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String curRow;
        int n = Integer.parseInt(br.readLine());
        StringBuilder answer = new StringBuilder("");
        while(n-- > 0){
            int optionsc = 1;
            int xc = 0;
            StringBuilder result = new StringBuilder("1x12 ");
            curRow = br.readLine();
            for(int i = 0; i < 12; i++)
                if(curRow.charAt(i) == 'X')
                   xc++;
            if(xc == 0){
                answer.append("0\n"); continue;
            }
            else if(xc == 1){
                result.append("1 1x12");
            }
            else{
              L: for(int i = 2; i <= 12; i++){
                    if(12 % i == 0){
                        switch(i){
                            case 2:
                                for(int j = 0; j <=5 ; j++ ){
                                    if( curRow.charAt(j) =='X'
                                      &&curRow.charAt(j) == curRow.charAt(j+6) )
                                    {
                                        result.append("2x6 ");
                                        optionsc++;
                                        break;
                                    }
                                }
                                break;

                            case 3:
                                for(int j = 0; j <= 3 ; j++ ){
                                    if( curRow.charAt(j) =='X'
                                      &&curRow.charAt(j) == curRow.charAt(j+4)
                                      &&curRow.charAt(j+8) == curRow.charAt(j))
                                    {
                                        result.append("3x4 ");
                                        optionsc++;
                                        break;
                                    }
                                }
                                break;

                            case 4:
                                for(int j = 0; j <= 2 ; j++ ){
                                    if( curRow.charAt(j) =='X'
                                      &&curRow.charAt(j) == curRow.charAt(j+3)
                                      &&curRow.charAt(j+6) == curRow.charAt(j)
                                      &&curRow.charAt(j+9) == curRow.charAt(j))
                                    {
                                        result.append("4x3 "); optionsc++;
                                        break;
                                    }
                                }
                                break;

                            case 6:
                                boolean out = false;
                                if(xc != 12 ){
                                    for(int m = 0 ; m <= 1 ; m++){
                                        if( curRow.charAt(m) =='X'
                                           &&curRow.charAt(m) == curRow.charAt(m+2)
                                           &&curRow.charAt(m) == curRow.charAt(m+4)
                                           &&curRow.charAt(m) == curRow.charAt(m+6)
                                           &&curRow.charAt(m) == curRow.charAt(m+8)
                                           &&curRow.charAt(m) == curRow.charAt(m+10))
                                        {
                                            result.append("6x2 ");
                                            optionsc++;
                                            break  ;
                                        }
                                    }
                                }else{
                                    result.append("6x2 ");
                                    optionsc++;
                                    break;
                                }
                                break;

                            case 12:
                                if(xc == 12){
                                    result.append("12x1 ");
                                    optionsc++;
                                }
                                break;
                        }
                    }
                }
            }
            answer.append(optionsc + " " + result + "\n");
        }
        System.out.println(answer);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.util.StringTokenizer;
import java.io.InputStreamReader;
public class Solution {
    public static void main(String []args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String curRow;
        int n = Integer.parseInt(br.readLine());
        StringBuilder answer = new StringBuilder("");
        while(n-- > 0){
            int optionsc = 1;
            int xc = 0;
            StringBuilder result = new StringBuilder("1x12 ");
            curRow = br.readLine();
            for(int i = 0; i < 12; i++)
                if(curRow.charAt(i) == 'X')
                   xc++;
            if(xc == 0){
                answer.append("0\n"); continue;
            }
            else if(xc == 1){
               answer.append("1 1x12\n"); continue;
            }
            else{
              L: for(int i = 2; i <= 12; i++){
                    if(12 % i == 0){
                        switch(i){
                            case 2:
                                for(int j = 0; j <=5 ; j++ ){
                                    if( curRow.charAt(j) =='X'
                                      &&curRow.charAt(j) == curRow.charAt(j+6) )
                                    {
                                        result.append("2x6 ");
                                        optionsc++;
                                        break;
                                    }
                                }
                                break;

                            case 3:
                                for(int j = 0; j <= 3 ; j++ ){
                                    if( curRow.charAt(j) =='X'
                                      &&curRow.charAt(j) == curRow.charAt(j+4)
                                      &&curRow.charAt(j+8) == curRow.charAt(j))
                                    {
                                        result.append("3x4 ");
                                        optionsc++;
                                        break;
                                    }
                                }
                                break;

                            case 4:
                                for(int j = 0; j <= 2 ; j++ ){
                                    if( curRow.charAt(j) =='X'
                                      &&curRow.charAt(j) == curRow.charAt(j+3)
                                      &&curRow.charAt(j+6) == curRow.charAt(j)
                                      &&curRow.charAt(j+9) == curRow.charAt(j))
                                    {
                                        result.append("4x3 "); optionsc++;
                                        break;
                                    }
                                }
                                break;

                            case 6:
                                boolean out = false;
                                if(xc != 12 ){
                                    for(int m = 0 ; m <= 1 ; m++){
                                        if( curRow.charAt(m) =='X'
                                           &&curRow.charAt(m) == curRow.charAt(m+2)
                                           &&curRow.charAt(m) == curRow.charAt(m+4)
                                           &&curRow.charAt(m) == curRow.charAt(m+6)
                                           &&curRow.charAt(m) == curRow.charAt(m+8)
                                           &&curRow.charAt(m) == curRow.charAt(m+10))
                                        {
                                            result.append("6x2 ");
                                            optionsc++;
                                            break  ;
                                        }
                                    }
                                }else{
                                    result.append("6x2 ");
                                    optionsc++;
                                    break;
                                }
                                break;

                            case 12:
                                if(xc == 12){
                                    result.append("12x1 ");
                                    optionsc++;
                                }
                                break;
                        }
                    }
                }
            }
            answer.append(optionsc + " " + result + "\n");
        }
        System.out.println(answer);
    }
}


import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class InnaAndChooseOptions {
	public static void main(String[]args) throws IOException {

		PrintWriter pw = new PrintWriter(System.out);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int c =0;
		ArrayList<String> possibles = new ArrayList<>();
		ArrayList<String> cases = new ArrayList<>();
		int n = Integer.parseInt(br.readLine());
		for(int i= 0; i<n; i++) {
			cases.add(br.readLine());
			if(cases.get(i).equals("OOOOOOOOOOOO"))
				pw.print("0");
			if(cases.get(i).equals("XXXXXXXXXXXX"))
				pw.print("6 1x12 2x6 3x4 4x3 6x2 12x1");
			else {
				c=1;
				possibles.add("1x12");
				for(int d=0; d<6; d++) {
					if(cases.get(i).charAt(d) == cases.get(i).charAt(d+6) && cases.get(i).charAt(d)== 'X') {
						c++;
						possibles.add("2x6");
						break;
					}
				}
				for(int j =0; j<4; j++) {
					if(cases.get(i).charAt(j)== 'X' && cases.get(i).charAt(j) == cases.get(i).charAt(j+4) && cases.get(i).charAt(j) == cases.get(i).charAt(j+8)) {
						c++;
						possibles.add("3x4");
						break;
					}
				}
				for(int k =0; k<3; k++) {
					if(cases.get(i).charAt(k)== 'X' && cases.get(i).charAt(k) == cases.get(i).charAt(k+3) && cases.get(i).charAt(k) == cases.get(i).charAt(k+6) && cases.get(i).charAt(k) == cases.get(i).charAt(k+9)) {
						c++;
						possibles.add("4x3");
						break;
					}
				}
				for(int l =0; l<2; l++) {
					if(cases.get(i).charAt(l)== 'X' && cases.get(i).charAt(l) == cases.get(i).charAt(l+2) && cases.get(i).charAt(l) == cases.get(i).charAt(l+4) && cases.get(i).charAt(l) == cases.get(i).charAt(l+8) && cases.get(i).charAt(l) == cases.get(i).charAt(l+10)){
						c++;
						possibles.add("6x2");
						break;
					}
				}
				pw.print(c + " ");
				for(int r =0; r< possibles.size()-1; r++) {
					pw.print(possibles.get(r) + " ");
				}
				pw.print(possibles.get(possibles.size()-1));
				pw.println();
			}
			c=0;
			for(int r =0; r< possibles.size(); r++) {
				possibles.remove(r);
			}

		}

			pw.close();
	}

}


import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class InnaAndChooseOptions {
	public static void main(String[]args) throws IOException {

		PrintWriter pw = new PrintWriter(System.out);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int c =0;
		ArrayList<String> possibles = new ArrayList<>();
		ArrayList<String> cases = new ArrayList<>();
		int n = Integer.parseInt(br.readLine());
		for(int i= 0; i<n; i++) {
			cases.add(br.readLine());
			if(cases.get(i).equals("OOOOOOOOOOOO")) {
				pw.print("0");
				pw.println();

			}
			else if(cases.get(i).equals("XXXXXXXXXXXX")) {
				pw.print("6 1x12 2x6 3x4 4x3 6x2 12x1");
				pw.println();
			}
			else {
				c=1;
				possibles.add("1x12");
				for(int d=0; d<6; d++) {
					if(cases.get(i).charAt(d) == cases.get(i).charAt(d+6) && cases.get(i).charAt(d)== 'X') {
						c++;
						possibles.add("2x6");
						break;
					}
				}
				for(int j =0; j<4; j++) {
					if(cases.get(i).charAt(j)== 'X' && cases.get(i).charAt(j) == cases.get(i).charAt(j+4) && cases.get(i).charAt(j) == cases.get(i).charAt(j+8)) {
						c++;
						possibles.add("3x4");
						break;
					}
				}
				for(int k =0; k<3; k++) {
					if(cases.get(i).charAt(k)== 'X' && cases.get(i).charAt(k) == cases.get(i).charAt(k+3) && cases.get(i).charAt(k) == cases.get(i).charAt(k+6) && cases.get(i).charAt(k) == cases.get(i).charAt(k+9)) {
						c++;
						possibles.add("4x3");
						break;
					}
				}
				for(int l =0; l<2; l++) {
					if(cases.get(i).charAt(l)== 'X' && cases.get(i).charAt(l) == cases.get(i).charAt(l+2) && cases.get(i).charAt(l) == cases.get(i).charAt(l+4) && cases.get(i).charAt(l) == cases.get(i).charAt(l+8) && cases.get(i).charAt(l) == cases.get(i).charAt(l+10)){
						c++;
						possibles.add("6x2");
						break;
					}
				}
				pw.print(c + " ");
				for(int r =0; r< possibles.size()-1; r++) {
					pw.print(possibles.get(r) + " ");
				}
				pw.print(possibles.get(possibles.size()-1));
				pw.println();
			}
			c=0;
			for(int r =0; r< possibles.size(); r++) {
				possibles.remove(r);
			}

		}

			pw.close();
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Rana {
	public static boolean check( ArrayList<String> idx, int k) {
		int c=0;
		int h =0;
		for(int i =0; i<idx.size() && h<12/k;i++) {
			if(idx.get(i).charAt(h)=='X') {
				c++;
				if(c==idx.size()) {
					return true;
				}
			}
			else {
					c=0;
					i=-1;
					h++;
				}
			}
		return false;
		}

    public static void main(String[] args) throws IOException{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    String sb = "";
    String s ="";
    int count =1;
    int n=Integer.parseInt(br.readLine());
    for(int l=0; l<n;l++) {
    	StringBuilder x = new StringBuilder();
    	count=1;
		String st = br.readLine();
		if(st.equals("OOOOOOOOOOOO"))
			System.out.println("0");

		else if(st.equals("XXXXXXXXXXXX"))
			System.out.println("6 1x12 2x6 3x4 4x3 6x2 12x1");

		else if (st.equals("XOXOXOXOXOXO") || st.equals("OXOXOXOXOXOX"))
			System.out.println("4 1x12 2x6 3x4 6x2");

		else {
		int k =1;
		while(k<7) {
			ArrayList<String> idx = new ArrayList<String>();
			if(k!=5) {

				for(int i=0;i<st.length();i+=(12/k)) {
					for(int j=0;j<(12/k);j++) {
						sb += st.charAt(j+i);
					}
					idx.add(sb);
					sb = "";
				}
				if(check(idx,k)) {
					count++;
					s+= "" + k + "x"+ 12/k + "  ";
				}
			}
			idx.clear();
			k++;

		}
    	}
		count--;
		if(count !=0)
		System.out.println(x.append(count + " " + s));
		s="";
    }
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Scanner;

public class InnaAndChooseOptions {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

		int tests = Integer.parseInt(br.readLine());

		for(int i=0; i<tests; i++) {
			String current = br.readLine();
			String mes = "";
			int count = 0;

			String[] listOfRows = new String[15];
			fill(listOfRows,current);
			if(current.contains("X")){
				mes+="1x12 ";
				count++;
			}
			for(int j=0; j<6;j++) {
				if(listOfRows[0].charAt(j)=='X' && listOfRows[0].charAt(j)==listOfRows[1].charAt(j)) {
					mes+="2x6 ";
					count++;
					break;
				}
			}
			for(int j=0; j<4;j++) {
				if(listOfRows[2].charAt(j)=='X' &&listOfRows[2].charAt(j)==listOfRows[3].charAt(j) && listOfRows[2].charAt(j)== listOfRows[4].charAt(j)) {
					mes+="3x4 ";
					count++;
					break;
				}
			}

			for(int j=0; j<3;j++) {
				if(listOfRows[5].charAt(j)=='X'&& listOfRows[5].charAt(j)==listOfRows[6].charAt(j) && listOfRows[5].charAt(j)== listOfRows[7].charAt(j)
						&& listOfRows[5].charAt(j)==listOfRows[8].charAt(j)) {
					mes+="4x3 ";
					count++;
					break;
				}
			}

			for(int j=0; j<2;j++) {
				if(listOfRows[9].charAt(j)=='X'&&listOfRows[9].charAt(j)==listOfRows[10].charAt(j) && listOfRows[9].charAt(j)== listOfRows[11].charAt(j)
						&& listOfRows[9].charAt(j)==listOfRows[12].charAt(j) && listOfRows[9].charAt(j)==listOfRows[13].charAt(j)
						&& listOfRows[9].charAt(j)==listOfRows[14].charAt(j)) {
					mes+="6x2 ";
					count++;
					break;
				}
			}

			if(current.contains("XXXXXXXXXXXX")) {
				mes+="12x1";
				count++;
			}

			out.println(count+ " " + mes);

		}
		out.flush();
	}

	public static void fill(String[] rows, String current) {
		rows[0] = current.substring(0, 6);
		rows[1] = current.substring(6, 12);
		rows[2] = current.substring(0,4);
		rows[3] = current.substring(4,8);
		rows[4] = current.substring(8,12);
		rows[5] = current.substring(0,3);
		rows[6] = current.substring(3,6);
		rows[7] = current.substring(6,9);
		rows[8] = current.substring(9,12);
		rows[9] = current.substring(0,2);
		rows[10] = current.substring(2,4);
		rows[11] = current.substring(4,6);
		rows[12] = current.substring(6,8);
		rows[13] = current.substring(8,10);
		rows[14] = current.substring(10,12);

	}
}


import java.util.*;
import java.io.*;

public class innaandchooseoptions {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        String[]x = new String[t];
        String empty = sc.nextLine();
        int c = 0; boolean one = false; boolean two = false; boolean three = false;
        boolean four = false; boolean six = false; boolean twelve = false;
        for(int i = 0; i<t; i++){x[i]=sc.nextLine();}
        for(int i = 0; i<t; i++){
            one = false; two = false; three = false;
            four = false; six = false; twelve = false; c = 0;
            if(x[i].charAt(0)=='X' && x[i].charAt(1)=='X' && x[i].charAt(2)=='X' && x[i].charAt(3)=='X' && x[i].charAt(4)=='X' && x[i].charAt(5)=='X' && x[i].charAt(6)=='X' && x[i].charAt(7)=='X' && x[i].charAt(8)=='X' && x[i].charAt(9)=='X' && x[i].charAt(10)=='X' && x[i].charAt(11)=='X'){
                c++; twelve=true;}
            for(int j = 0; j<2; j++){
                if(x[i].charAt(j)=='X' && x[i].charAt(j+2)=='X' && x[i].charAt(j+4)=='X' && x[i].charAt(j+6)=='X' && x[i].charAt(j+8)=='X' && x[i].charAt(j+10)=='X'){
                    c++; six=true; break;}}
            for(int j = 0; j<3; j++){
                if(x[i].charAt(j)=='X' && x[i].charAt(j+3)=='X' && x[i].charAt(j+6)=='X' && x[i].charAt(j+9)=='X'){
                    c++; four=true; break;}}
            for(int j = 0; j<4; j++){
                if(x[i].charAt(j)=='X' && x[i].charAt(j+4)=='X' && x[i].charAt(j+8)=='X'){
                    c++; three=true; break;}}
            for(int j = 0; j<6; j++){
                if(x[i].charAt(j)=='X' && x[i].charAt(j+6)=='X'){
                    c++; two = true; break;}}
            for(int j = 0; j<12; j++){
                if(x[i].charAt(j)=='X'){
                        c++; one = true; break;}}

                    System.out.print(c); System.out.print(" ");
                    if(one){ System.out.print("1x12"); System.out.print(" ");}
                    if(two){ System.out.print("2x6"); System.out.print(" ");}
                    if(three){ System.out.print("3x4"); System.out.print(" ");}
                    if(four){ System.out.print("4x3"); System.out.print(" ");}
                    if(six){ System.out.print("6x2"); System.out.print(" ");}
                    if(twelve){ System.out.print("12x1"); System.out.print(" ");}
                    System.out.println("");
        }
    }
}


import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A1008 {
    public static void main(String [] args) /*throws Exception*/ {
        InputStream inputReader = System.in;
        OutputStream outputReader = System.out;
        InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File("input.txt")));new InputReader(inputReader);
        PrintWriter out = new PrintWriter(outputReader);//new PrintWriter(new FileOutputStream(new File("output.txt")));
        Algorithm solver = new Algorithm();
        solver.solve(in, out);
        out.close();
    }
}

class Algorithm {
    void solve(InputReader ir, PrintWriter pw) {

        int t = ir.nextInt();
        String s;
        int [] array = {1, 2, 3, 4, 6, 12};
        for(int tt = 0; tt < t; ++tt) {
            s = ir.next();
            ArrayList<String> ans = new ArrayList<>();
            for (int a : array) {
                for (int i = 0; i < 12 / a; ++i) {
                    boolean can = true;
                    for (int j = i; j < 12; j += 12 / a) can = can && s.charAt(j) == 'X';
                    if (can) {
                        ans.add(a + "x" + 12 / a);
                        break;
                    }
                }
            }
            pw.print(ans.size() + " ");
            for (String cur : ans) pw.print(cur + " ");
            pw.println();
        }
    }

    private static void Qsort(int[] array, int low, int high) {

        int i = low;
        int j = high;
        int x = array[low + (high - low) / 2];

        do {
            while (array[i] < x) ++i;
            while (array[j] > x) --j;
            if (i <= j) {
                int tmp = array[i];
                array[i] = array[j];
                array[j] = tmp;
                i++;
                j--;
            }
        } while (i <= j);

        if (low < j) Qsort(array, low, j);
        if (i < high) Qsort(array, i, high);

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    String nextLine(){
        String fullLine = null;
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                fullLine = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return fullLine;
        }
        return fullLine;
    }

    String [] toArray() {
        return nextLine().split(" ");
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }

}


import java.util.Scanner;

/**
 * Created by rafael on 4/28/14.
 */
public class Codeforces234A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int t = in.nextInt(); in.nextLine();

        for (int i = 0; i < t; i++) {
            String s = in.nextLine();
            char[] ta = s.toCharArray();

            int n1x12 = 0,n2x6 = 0,n3x4 = 0,n4x3 = 0,n6x2 = 0,n12x1 = 0;

            for (int j = 0; j < ta.length; j++) {
                if (ta[j] == 'X') {
                    n1x12 = 1;
                    break;
                }
            }
            for (int j = 0; j < 6; j++) {
                int count = 0;
                for (int k = 0; k < 2; k++) {
                    count += ta[k*6 + j] == 'X' ? 1 : 0;
                }
                n2x6 = count == 2 ? 1 : n2x6;
            }
            for (int j = 0; j < 4; j++) {
                int count = 0;
                for (int k = 0; k < 3; k++) {
                    count += ta[k*4 + j] == 'X' ? 1 : 0;
                }
                n3x4 = count == 3 ? 1 : n3x4;
            }
            for (int j = 0; j < 3; j++) {
                int count = 0;
                for (int k = 0; k < 4; k++) {
                    count += ta[k*3 + j] == 'X' ? 1 : 0;
                }
                n4x3 = count == 4 ? 1 : n4x3;
            }
            for (int j = 0; j < 2; j++) {
                int count = 0;
                for (int k = 0; k < 6; k++) {
                    count += ta[k*2 + j] == 'X' ? 1 : 0;
                }
                n6x2 = count == 6 ? 1 : n6x2;
            }
            for (int j = 0; j < 1; j++) {
                int count = 0;
                for (int k = 0; k < 12; k++) {
                    count += ta[k + j] == 'X' ? 1 : 0;
                }
                n12x1 = count == 12 ? 1 : n12x1;
            }

            int tot = n1x12 + n2x6 + n3x4 + n4x3 + n6x2 + n12x1;
            System.out.print(tot + " ");
            if (n1x12 == 1) System.out.print("1x12 ");
            if (n2x6 == 1) System.out.print("2x6 ");
            if (n3x4 == 1) System.out.print("3x4 ");
            if (n4x3 == 1) System.out.print("4x3 ");
            if (n6x2 == 1) System.out.print("6x2 ");
            if (n12x1 == 1) System.out.print("12x1");
            System.out.println();
        }
    }
}


import java.util.Scanner;

/**
 * Created by rafael on 4/28/14.
 */
public class Codeforces234A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int t = in.nextInt(); in.nextLine();

        for (int i = 0; i < t; i++) {
            String s = in.nextLine();
            char[] ta = s.toCharArray();

            int n1x12 = 0,n2x6 = 0,n3x4 = 0,n4x3 = 0,n6x2 = 0,n12x1 = 0;

            for (int j = 0; j < ta.length; j++) {
                if (ta[j] == 'X') {
                    n1x12 = 1;
                    break;
                }
            }
            for (int j = 0; j < 6; j++) {
                if (ta[i] == 'X' && ta[i + 6] == 'X') {
                    n2x6 = 1;
                    break;
                }
            }
            for (int j = 0; j < 4; j++) {
                if (ta[i] == 'X' && ta[i + 4] == 'X' && ta[i + 8] == 'X') {
                    n3x4 = 1;
                    break;
                }
            }
            for (int j = 0; j < 3; j++) {
                if (ta[i] == 'X' && ta[i + 3] == 'X' && ta[i + 6] == 'X' && ta[i + 9] == 'X') {
                    n4x3 = 1;
                    break;
                }
            }
            for (int j = 0; j < 2; j++) {
                int count = 0;
                for (int k = 0; k < 6; k++) {
                    count += ta[k*2 + j] == 'X' ? 1 : 0;
                }
                n6x2 = count == 6 ? 1 : n6x2;
            }
            for (int j = 0; j < 1; j++) {
                int count = 0;
                for (int k = 0; k < 12; k++) {
                    count += ta[k + j] == 'X' ? 1 : 0;
                }
                n12x1 = count == 12 ? 1 : n12x1;
            }

            int tot = n1x12 + n2x6 + n3x4 + n4x3 + n6x2 + n12x1;
            System.out.print(tot + " ");
            if (n1x12 == 1) System.out.print("1x12 ");
            if (n2x6 == 1) System.out.print("2x6 ");
            if (n3x4 == 1) System.out.print("3x4 ");
            if (n4x3 == 1) System.out.print("4x3 ");
            if (n6x2 == 1) System.out.print("6x2 ");
            if (n12x1 == 1) System.out.print("12x1");
            System.out.println();
        }
    }
}


import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
Scanner sc =new Scanner(System.in);
        int n= sc.nextInt();
        sc.nextLine();
        for(int line =1 ; line<=n;line++){
            String s= sc.nextLine();
            int c=0;
            String r="";
            for(int a=1;a<=12;a++){
                if(12%a==0){
                    int b= 12/a;
                    int target=a;
                    for(int i=0;i<12&&target>0;){
                        if(s.charAt(i)=='X'){
                            target--;
                            i+=b;

                        }else{
                            i++;
                            if(i%b==0)
                                break;
                             i=i%b;
                            target=a;
                        }
                    }
                    if(target==0){
                        r+=" "+a+"x"+b;
                        c++;

                    }

                }
            }
            r=c+r;
            System.out.println(r);
        }
    }
}


import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        //BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
       Scanner sc =new Scanner(System.in);
        int n= sc.nextInt();
        sc.nextLine();
       for(int line=1;line<=n;line++){
           String s =sc.nextLine();
                      int c=0;
           String r="";

           for(int a=1;a<=12;a++){
               if(12%a==0){
                   int b= 12/a;
                   int target=a;
                   boolean exist=false;
                   for(int j=0;j+b<s.length();){
                       if(s.charAt(j)=='X'){
                           target--;
                           if(target>0&&s.charAt(j+b)=='X'){
                           j=j+b;
                           if(j+b>=12)
                           exist=true;
                           c++;
                       }
                       }else{
                           j++;
                           j=j%b;
                           target=a;
                       }
                   }
                   if(exist){
                       r=r+" "+a+"x"+b;

                   }
               }
           }

               r=c+r;
               System.out.println(r);

       }
    }
}


import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        for (int line = 1; line <= n; line++) {
            String s = sc.nextLine();
            String r="";
            int c=0;
            for(int a=1;a<=12;a++){
                boolean isIn=false;
                if(12%a==0){
                    int d=12/a;
                    label :for(int i=0;i<d;i++){
                        for(int j=i;j<12;j+=d){
                            if(s.charAt(j)=='X'){
                                if(j+d>=12){
                                    isIn=true;
                                }
                            }else{
                                continue label;
                            }
                        }

                    }
                    if(isIn){
                        r=r+" "+a+"x"+d;
                        c++;
                    }

                }
            }
r=c+r;
            System.out.println(r);
        }

    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Prac {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);

        int t=sc.nextInt();
        while(t>0){
            String str=sc.next();
            String ans=" ";
            int s=0,i;
            for(i=0;i<12;i++)
                if(str.charAt(i)=='X'){
                    s++;
                    ans+="1x12 ";
                    break;
                }
            for(i=0;i<6;i++)
                if(str.charAt(i)=='X'&&str.charAt(i+6)=='X'){
                    s++;
                    ans+="2x6 ";
                    break;
                }
            for(i=0;i<4;i++)
                if(str.charAt(i)=='X'&&str.charAt(i+4)=='X'&&str.charAt(i+8)=='X'){
                    s++;
                    ans+="3x4 ";
                    break;
                }
            for(i=0;i<3;i++)
                if(str.charAt(i)=='X'&&str.charAt(i+3)=='X'&&str.charAt(i+6)=='X'&&str.charAt(i+9)=='X')
                {
                    s++;
                    ans+="4x3 ";
                    break;
                }
            for(i=0;i<2;i++)
                if(str.charAt(i)=='X'&&str.charAt(i+2)=='X'&&str.charAt(i+4)=='X'&&str.charAt(i+6)=='X'&&str.charAt(i+8)=='X'&&str.charAt(i+10)=='X'){
                    s++;
                    ans+="6x2 ";
                    break;
            }
            int count=0;
            for(i=0;i<12;i++)
                if(str.charAt(i)=='X')
                    count++;
            if(count==12){
                s++;
                ans+="12x1 ";
            }
            String print=s+ans;
            System.out.println(print);
            t--;
        }

    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Prac {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);

        int t=sc.nextInt();
        while(t>0){
            String str=sc.next();
            String ans=" ";
            int s=0,i;
            for(i=0;i<12;i++)
                if(str.charAt(i)=='X'){
                    s++;
                    ans+="1*12 ";
                    break;
                }
            for(i=0;i<6;i++)
                if(str.charAt(i)=='X'&&str.charAt(i+6)=='X'){
                    s++;
                    ans+="2*6 ";
                    break;
                }
            for(i=0;i<4;i++)
                if(str.charAt(i)=='X'&&str.charAt(i+4)=='X'&&str.charAt(i+8)=='X'){
                    s++;
                    ans+="3*4 ";
                    break;
                }
            for(i=0;i<3;i++)
                if(str.charAt(i)=='X'&&str.charAt(i+3)=='X'&&str.charAt(i+6)=='X'&&str.charAt(i+9)=='X')
                {
                    s++;
                    ans+="4*3 ";
                    break;
                }
            for(i=0;i<2;i++)
                if(str.charAt(i)=='X'&&str.charAt(i+2)=='X'&&str.charAt(i+4)=='X'&&str.charAt(i+6)=='X'&&str.charAt(i+8)=='X'&&str.charAt(i+10)=='X'){
                    s++;
                    ans+="6*2 ";
                    break;
            }
            int count=0;
            for(i=0;i<12;i++)
                if(str.charAt(i)=='X')
                    count++;
            if(count==12){
                s++;
                ans+="12*1 ";
            }
            String print=s+ans;
            System.out.println(print);
            t--;
        }

    }
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String []args) {
      Scanner sc= new Scanner (System.in);
      int n=sc.nextInt();
      String [] s=new String [n];
      for(int i=0; i<n;i++)
    	  s[i]=sc.next();
      for(int i=0; i<n;i++) {
    	  String s1=s[i];
    	  int count =0;
    	  String result ="";
    	  if(s1.contains("X")) {
    		  count++;
    		  result=" "+"1x12";
    	  }
    	  if((s1.charAt(0)==s1.charAt(6)&&s1.charAt(6)=='X')||(s1.charAt(1)==s1.charAt(7)&&s1.charAt(7)=='X')||(s1.charAt(2)==s1.charAt(8)&&s1.charAt(8)=='X')||(s1.charAt(3)==s1.charAt(9)&&s1.charAt(9)=='X')||(s1.charAt(4)==s1.charAt(10)&&s1.charAt(10)=='X')||(s1.charAt(5)==s1.charAt(11)&&s1.charAt(11)=='X')) {
    		  count++;
    		  result+=" "+"2x6";
    	  }
    	  if((s1.charAt(0)==s1.charAt(4)&&s1.charAt(4)==s1.charAt(8)&&s1.charAt(8)=='X')||(s1.charAt(1)==s1.charAt(5)&&s1.charAt(5)==s1.charAt(9)&&s1.charAt(9)=='X')||(s1.charAt(2)==s1.charAt(6)&&s1.charAt(6)==s1.charAt(10)&&s1.charAt(10)=='X')||(s1.charAt(3)==s1.charAt(7)&&s1.charAt(7)==s1.charAt(11)&&s1.charAt(11)=='X')) {
    		  count++;
    		  result+=" "+"3x4";
    	  }
    	  if((s1.charAt(0)==s1.charAt(3)&&s1.charAt(0)==s1.charAt(6)&&s1.charAt(0)==s1.charAt(9)&&s1.charAt(0)=='X')||(s1.charAt(1)==s1.charAt(4)&&s1.charAt(1)==s1.charAt(7)&&s1.charAt(1)==s1.charAt(10)&&s1.charAt(1)=='X')||(s1.charAt(2)==s1.charAt(5)&&s1.charAt(2)==s1.charAt(8)&&s1.charAt(2)==s1.charAt(11)&&s1.charAt(2)=='X') ){
    		  count++;
    		  result+=" "+"4x3";
    	  }
    	  if((s1.charAt(0)==s1.charAt(2)&&s1.charAt(0)==s1.charAt(4)&&s1.charAt(0)==s1.charAt(6)&&s1.charAt(0)==s1.charAt(8)&&s1.charAt(0)==s1.charAt(10)&&s1.charAt(0)=='X')|| (s1.charAt(1)==s1.charAt(3)&&s1.charAt(1)==s1.charAt(5)&&s1.charAt(1)==s1.charAt(7)&&s1.charAt(1)==s1.charAt(9)&&s1.charAt(1)==s1.charAt(11)&&s1.charAt(1)=='X')){
    		  count++;
    		  result+=" "+"6x2";
    	  }
    	  if(s1.contains("XXXXXXXXXXXX")) {
    		  count++;
    		  result+=" "+"12x1";
    	  }
    	  System.out.print(count +" ");
    	  System.out.println(result);
      }
 	}
}


import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        byte t = (byte) scanner.nextShort();
        String S;
        String[] O = {"", "", "", "", "", ""};
        byte w = 0;
        boolean x = false;

        for (int i = 0; i < t; i++) {
            S = scanner.next();
            for (int j = 0; j < S.length(); j++) {
                if (S.charAt(j) == 'X') {O[0] = "1x12 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 6; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 6) == 'X') {O[1] = "2x6 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 8; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 4) == 'X' && S.charAt(j + 8) == 'X') {O[2] = "3x4 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 9; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 3) == 'X' && S.charAt(j + 6) == 'X' && S.charAt(j + 9) == 'X') {O[3] = "4x3 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 10; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 2) == 'X' && S.charAt(j + 4) == 'X' && S.charAt(j + 6) == 'X' && S.charAt(j + 8) == 'X' && S.charAt(j + 10) == 'X')
                {O[4] = "6x2 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 1; j++) {
                x = (S.charAt(j) == 'X' && S.charAt(j + 1) == 'X');
            }
            if (x) {O[5] = "12x1 "; w++;}
            writer.print(w);
            if (w != 0) writer.print(" ");
            w = 0;
            for (int j = 0; j < O.length; j++) {
                writer.print(O[j]);
                O[j] = "";
            }
            writer.println();
        }
        writer.close();
    }
}


import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        byte t = (byte) scanner.nextShort();
        String S;
        String[] O = {"", "", "", "", "", ""};
        byte w = 0;
        boolean x = false;

        for (int i = 0; i < t; i++) {
            S = scanner.next();
            for (int j = 0; j < S.length(); j++) {
                if (S.charAt(j) == 'X') {O[0] = "1x12 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 6; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 6) == 'X') {O[1] = "2x6 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 8; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 4) == 'X' && S.charAt(j + 8) == 'X') {O[2] = "3x4 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 9; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 3) == 'X' && S.charAt(j + 6) == 'X' && S.charAt(j + 9) == 'X') {O[3] = "4x3 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 10; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 2) == 'X' && S.charAt(j + 4) == 'X' && S.charAt(j + 6) == 'X' && S.charAt(j + 8) == 'X' && S.charAt(j + 10) == 'X')
                {O[4] = "6x2 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 1; j++) {
                x = (S.charAt(i) == 'X' && S.charAt(i + 1) == 'X');
            }
            if (x) {O[5] = "12x1 "; w++;}
            writer.print(w);
            if (w != 0) writer.print(" ");
            w = 0;
            for (int j = 0; j < O.length; j++) {
                writer.print(O[j]);
                O[j] = "";
            }
            writer.println();
        }
        writer.close();
    }
}


import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        byte t = (byte) scanner.nextShort();
        String S;
        String[] O = {"", "", "", "", "", ""};
        byte w = 0;
        boolean x = false;

        for (int i = 0; i < t; i++) {
            S = scanner.next();
            for (int j = 0; j < S.length(); j++) {
                if (S.charAt(j) == 'X') {O[0] = "1x12 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 6; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 6) == 'X') {O[1] = "2x6 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 8; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 4) == 'X' && S.charAt(j + 8) == 'X') {O[2] = "3x4 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 9; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 3) == 'X' && S.charAt(j + 6) == 'X' && S.charAt(j + 9) == 'X') {O[3] = "4x3 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 10; j++) {
                if (S.charAt(j) == 'X' && S.charAt(j + 2) == 'X' && S.charAt(j + 4) == 'X' && S.charAt(j + 6) == 'X' && S.charAt(j + 8) == 'X' && S.charAt(j + 10) == 'X')
                {O[4] = "6x2 "; w++; break;}
            }
            for (int j = 0; j < S.length() - 1; j++) {
                if (!(x = (S.charAt(j) == 'X' && S.charAt(j + 1) == 'X'))) break;
            }
            if (x) {O[5] = "12x1 "; w++;}
            writer.print(w);
            if (w != 0) writer.print(" ");
            w = 0;
            for (int j = 0; j < O.length; j++) {
                writer.print(O[j]);
                O[j] = "";
            }
            writer.println();
        }
        writer.close();
    }
}


import java.util.Scanner;

public class CF400A {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = {1, 2, 3, 4, 6, 12};
        for (int i = 0; i < n; i++) {
            String s = sc.next(), ans = "";
            int C = 0;
            char ch[] = s.toCharArray();
            for (int j = 0; j < 6; j++) {

                for (int l = 0; l <= 12 / a[j]; l++) {
                    int c = 0;
                    for (int k = l; k < 12; k += a[j]) {
                        if (ch[k] == 'X') {
                            c++;
                        }
                    }
                    if (c == 12 / a[j]) {
                        C++;
                        ans = (12 / a[j])+ "x"+ a[j] +" "+ans ;
                        break;
                    }
                }
            }
            System.out.println(C + " " + ans);
        }
    }
}


import java.util.Scanner;

public class CF400A {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = {1, 2, 3, 4, 6, 12};
        for (int i = 0; i < n; i++) {
            String s = sc.next(), ans = "";
            int C = 0;
            char ch[] = s.toCharArray();
            for (int j=0;j<6;j++){
                for(int k=0;k<12/a[j];k++){
                    int c=0;
                    for(int l=k;l<12;l+=12/a[j]){
                        if(ch[l]=='X'){
                            c++;
                        }
                    }
                    if(c==a[j]){
                        C++;
                        ans=ans+" "+a[j]+"x"+12/a[j];
                        break;
                    }
                }
            }
            System.out.println(C+ ans);
        }
    }
}

//4
//OXXXOXOOXOOX
//OXOXOXOXOXOX
//XXXXXXXXXXXX
//OOOOOOOOOOOO


import java.util.Scanner;

public class CF400A {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = {1, 2, 3, 4, 6, 12};
        for (int i = 0; i < n; i++) {
            String s = sc.next(), ans = "";
            int C = 0;
            char ch[] = s.toCharArray();
            for (int j = 0; j < 6; j++) {

                for (int l = 0; l < 12 / a[j]; l++) {
                    int c = 0;
                    for (int k = l; k < 12; k += a[j]) {
                        if (ch[k] == 'X') {
                            c++;
                        }
                    }
                    if (c == 12 / a[j]) {
                        C++;
                        ans = (12 / a[j])+ "x"+ a[j] +" "+ans ;
                        break;
                    }
                }
            }
            System.out.println(C + " " + ans);
        }
    }
}


import java.util.*;
public class Test
{
	public static void main(String[]args)
	{
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		sc.nextLine();
		for(int p = 0 ; p<t ; p++)
		{
			String x ="";
			String y ="";
			String z="";
			String r="";
			String q ="";
			String h="";
			String s =sc.nextLine();
			String answer="";
			int count = 0;

			for(int i = 0 ; i<12;i++)
				if(s.charAt(i)=='X')
					{answer+=" 1x12";count++;break;}

			x="";
			y ="";
			z ="";
			h ="";
			r ="";
			q ="";
			for(int i = 0 ; i<12 ; i+=6)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
				r+=s.charAt(i+4);
				q+=s.charAt(i+5);
			}
			if(x.equals("XX")||y.equals("XX")||z.equals("XX")||h.equals("XX")||r.equals("XX")||q.equals("XX"))
					{answer+=" 2x6";count++;}

			x="";
			y ="";
			z ="";
			h ="";
			for(int i = 0 ; i<12 ; i+=4)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
			}
			if(x.equals("XXX")||y.equals("XXX")||z.equals("XXX")||h.equals("XXX"))
					{answer+=" 3x4";count++;}

			x="";
			y ="";
			z ="";
			for(int i = 0 ; i<12 ; i+=3)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
			}
			if(x.equals("XXXX")||y.equals("XXXX")||z.equals("XXXX"))
					{answer+=" 4x3";count++;}

			x="";
			y ="";
			for(int i = 0 ; i<12 ; i+=2)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
			}
			if(x.equals("XXXXXX")||y.equals("XXXXXX"))
					{answer+=" 6x2";count++;}

			if(s.equals("XXXXXXXXXXXX")) {answer+=" 12x1";count++;}

			System.out.println(count+answer);

		}

}

}


import java.util.*;
public class Test
{
	public static void main(String[]args)
	{
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		sc.nextLine();
		for(int p = 0 ; p<t ; p++)
		{
			String s =sc.nextLine();
			String answer="";
			int count = 0;
			boolean a = false, b= false , c=false ,d=false, e=false,f=false;
			for(int i = 0 ; i<12;i++)
				if(s.charAt(i)=='X')
					{answer+=" 12x1";count++;break;}
			String x="";
			String y ="";
			for(int i = 0 ; i<12 ; i+=2)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
			}
			if(x.equals("XXXXXX")||y.equals("XXXXXX"))
					{answer+=" 6x2";count++;}

			x="";
			y ="";
			String z ="";
			for(int i = 0 ; i<12 ; i+=3)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
			}
			if(x.equals("XXXX")||y.equals("XXXX")||z.equals("XXXX"))
					{answer+=" 4x3";count++;}

			x="";
			y ="";
			z ="";
			String h ="";
			for(int i = 0 ; i<12 ; i+=4)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
			}
			if(x.equals("XXX")||y.equals("XXX")||z.equals("XXX")||h.equals("XXX"))
					{answer+=" 3x4";count++;}

			x="";
			y ="";
			z ="";
			h ="";
			String r ="";
			String q ="";
			for(int i = 0 ; i<12 ; i+=6)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
				r+=s.charAt(i+4);
				q+=s.charAt(i+5);
			}
			if(x.equals("XX")||y.equals("XX")||z.equals("XX")||h.equals("XX")||r.equals("XX")||h.equals("XX"))
					{answer+=" 2x6";count++;}

			if(s.equals("XXXXXXXXXXXX")) {answer+=" 1x12";count++;}

			System.out.println(count+answer);

		}

}

}


import java.util.*;
public class Test
{
	public static void main(String[]args)
	{
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		sc.nextLine();
		for(int p = 0 ; p<t ; p++)
		{
			String x ="";
			String y ="";
			String z="";
			String r="";
			String q ="";
			String h="";
			String s =sc.nextLine();
			String answer="";
			int count = 0;

			for(int i = 0 ; i<12;i++)
				if(s.charAt(i)=='X')
					{answer+=" 1x12";count++;break;}

			x="";
			y ="";
			z ="";
			h ="";
			r ="";
			q ="";
			for(int i = 0 ; i<12 ; i+=6)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
				r+=s.charAt(i+4);
				q+=s.charAt(i+5);
			}
			if(x.equals("XX")||y.equals("XX")||z.equals("XX")||h.equals("XX")||r.equals("XX")||h.equals("XX"))
					{answer+=" 2x6";count++;}

			x="";
			y ="";
			z ="";
			h ="";
			for(int i = 0 ; i<12 ; i+=4)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
			}
			if(x.equals("XXX")||y.equals("XXX")||z.equals("XXX")||h.equals("XXX"))
					{answer+=" 3x4";count++;}

			x="";
			y ="";
			z ="";
			for(int i = 0 ; i<12 ; i+=3)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
			}
			if(x.equals("XXXX")||y.equals("XXXX")||z.equals("XXXX"))
					{answer+=" 4x3";count++;}

			x="";
			y ="";
			for(int i = 0 ; i<12 ; i+=2)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
			}
			if(x.equals("XXXXXX")||y.equals("XXXXXX"))
					{answer+=" 6x2";count++;}

			if(s.equals("XXXXXXXXXXXX")) {answer+=" 12x1";count++;}

			System.out.println(count+answer);

		}

}

}


package test;
import java.util.*;
public class Test
{
	public static void main(String[]args)
	{
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		sc.nextLine();
		for(int p = 0 ; p<t ; p++)
		{
			String x ="";
			String y ="";
			String z="";
			String r="";
			String q ="";
			String h="";
			String s =sc.nextLine();
			String answer="";
			int count = 0;

			for(int i = 0 ; i<12;i++)
				if(s.charAt(i)=='X')
					{answer+=" 1x12";count++;break;}

			x="";
			y ="";
			z ="";
			h ="";
			r ="";
			q ="";
			for(int i = 0 ; i<12 ; i+=6)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
				r+=s.charAt(i+4);
				q+=s.charAt(i+5);
			}
			if(x.equals("XX")||y.equals("XX")||z.equals("XX")||h.equals("XX")||r.equals("XX")||q.equals("XX"))
					{answer+=" 2x6";count++;}

			x="";
			y ="";
			z ="";
			h ="";
			for(int i = 0 ; i<12 ; i+=4)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
			}
			if(x.equals("XXX")||y.equals("XXX")||z.equals("XXX")||h.equals("XXX"))
					{answer+=" 3x4";count++;}

			x="";
			y ="";
			z ="";
			for(int i = 0 ; i<12 ; i+=3)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
			}
			if(x.equals("XXXX")||y.equals("XXXX")||z.equals("XXXX"))
					{answer+=" 4x3";count++;}

			x="";
			y ="";
			for(int i = 0 ; i<12 ; i+=2)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
			}
			if(x.equals("XXXXXX")||y.equals("XXXXXX"))
					{answer+=" 6x2";count++;}

			if(s.equals("XXXXXXXXXXXX")) {answer+=" 12x1";count++;}

			System.out.println(count+answer);

		}

}

}


import java.util.*;
public class Test
{
	public static void main(String[]args)
	{
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		sc.nextLine();
		for(int p = 0 ; p<t ; p++)
		{
			String x ="";
			String y ="";
			String z="";
			String r="";
			String q ="";
			String h="";
			String s =sc.nextLine();
			String answer="";
			int count = 0;
			boolean a = false, b= false , c=false ,d=false, e=false,f=false;
			for(int i = 0 ; i<12;i++)
				if(s.charAt(i)=='X')
					{answer+=" 1x12";count++;break;}
			x="";
			y ="";
			for(int i = 0 ; i<12 ; i+=2)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
			}
			if(x.equals("XXXXXX")||y.equals("XXXXXX"))
					{answer+=" 2x6";count++;}

			x="";
			y ="";
			z ="";
			for(int i = 0 ; i<12 ; i+=3)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
			}
			if(x.equals("XXXX")||y.equals("XXXX")||z.equals("XXXX"))
					{answer+=" 3x4";count++;}

			x="";
			y ="";
			z ="";
			h ="";
			for(int i = 0 ; i<12 ; i+=4)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
			}
			if(x.equals("XXX")||y.equals("XXX")||z.equals("XXX")||h.equals("XXX"))
					{answer+=" 4x3";count++;}

			x="";
			y ="";
			z ="";
			h ="";
			r ="";
			q ="";
			for(int i = 0 ; i<12 ; i+=6)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
				r+=s.charAt(i+4);
				q+=s.charAt(i+5);
			}
			if(x.equals("XX")||y.equals("XX")||z.equals("XX")||h.equals("XX")||r.equals("XX")||h.equals("XX"))
					{answer+=" 6x2";count++;}

			if(s.equals("XXXXXXXXXXXX")) {answer+=" 12x1";count++;}

			System.out.println(count+answer);

		}

}

}


import java.util.*;
public class Test
{
	public static void main(String[]args)
	{
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		sc.nextLine();
		for(int p = 0 ; p<t ; p++)
		{
			String s =sc.nextLine();
			String answer="";
			int count = 0;
			boolean a = false, b= false , c=false ,d=false, e=false,f=false;
			for(int i = 0 ; i<12;i++)
				if(s.charAt(i)=='X')
					{answer+=" 1x12";count++;break;}
			String x="";
			String y ="";
			for(int i = 0 ; i<12 ; i+=2)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
			}
			if(x.equals("XXXXXX")||y.equals("XXXXXX"))
					{answer+=" 2x6";count++;}

			x="";
			y ="";
			String z ="";
			for(int i = 0 ; i<12 ; i+=3)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
			}
			if(x.equals("XXXX")||y.equals("XXXX")||z.equals("XXXX"))
					{answer+=" 3x4";count++;}

			x="";
			y ="";
			z ="";
			String h ="";
			for(int i = 0 ; i<12 ; i+=4)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
			}
			if(x.equals("XXX")||y.equals("XXX")||z.equals("XXX")||h.equals("XXX"))
					{answer+=" 4x3";count++;}

			x="";
			y ="";
			z ="";
			h ="";
			String r ="";
			String q ="";
			for(int i = 0 ; i<12 ; i+=6)
			{
				x +=s.charAt(i);
				y+=s.charAt(i+1);
				z+=s.charAt(i+2);
				h+=s.charAt(i+3);
				r+=s.charAt(i+4);
				q+=s.charAt(i+5);
			}
			if(x.equals("XX")||y.equals("XX")||z.equals("XX")||h.equals("XX")||r.equals("XX")||h.equals("XX"))
					{answer+=" 6x2";count++;}

			if(s.equals("XXXXXXXXXXXX")) {answer+=" 12x1";count++;}

			System.out.println(count+answer);

		}

}

}


import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int tc = sc.nextInt();
        while (tc-- > 0) {
            StringBuilder ans = new StringBuilder();
            int counter = 0;
            char[] arr = sc.nextLine().toCharArray();
            for (int a = 1; a <= 12; a++) {
                for (int b = 12 / a; b <= 12; b++) {
                    if (a * b != 12) continue;
                    char[][] tmp = new char[a][b];
                    int idx = 0;
                    for (int i = 0; i < a; i++)
                        for (int j = 0; j < b; j++)
                            tmp[i][j] = arr[idx++];
                    if (check(tmp)) {
                        counter++;
                        ans.append(a + "x" + b + " ");
                    }
                }
            }

            out.println(counter + " " + ans.toString());
        }
        out.flush();
        out.close();
    }

    static boolean check(char[][] arr) {
        search:
        for (int j = 0; j < arr[0].length; j++) {
            for (int i = 0; i < arr.length; i++) {
                if (arr[i][j] == 'O') continue search;
            }
            return true;
        }
        return false;
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}