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

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

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

Input

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

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

Output

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

Examples

Input

4
OXXXOXOOXOOX
OXOXOXOXOXOX
XXXXXXXXXXXX
OOOOOOOOOOOO


Output

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

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		final int[] as = {1, 2, 3, 4, 6, 12};
		for(int caseIndex = 0; caseIndex < t; ++caseIndex) {
			char[] cards = in.next().toCharArray();
			ArrayList<Integer> results = new ArrayList<Integer>();
			for(int a: as) {
				int b = 12 / a;
				boolean isOK = false;
				for(int j = 0; j < b; ++j) {
					boolean isAllX = true;
					for(int i = 0; i < a; ++i) {
						if(cards[i * b + j] == 'O') {
							isAllX = false;
							break;
						}
					}
					
					if(isAllX) {
						isOK = true;
						break;
					}
				}
				
				if(isOK) {
					results.add(a);
				}
			}
			
			System.out.print(results.size());
			for(int a: results) {
				System.out.print(" " + a + "x" + (12 / a));
			}
			System.out.println();
		}
	}

}
// ///////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////

class Fun {
	public static int[] nextInts(Scanner in, int count) {
		int[] result = new int[count];
		for (int i = 0; i < count; ++i) {
			result[i] = in.nextInt();
		}
		return result;
	}
	
	public static boolean isPrime(int n) {
		boolean result = true;
		for(int i = 2; i * i <= n; ++i) {
			if(n % i == 0) {
				result = false;
				break;
			}
		}
		return result;
	}

	public static long gcd(long a, long b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	public static int gcd(int a, int b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	public static int[][] transpose(int[][] mat) {
		int r = mat.length;
		int c = mat[0].length;
		int[][] result = new int[c][r];
		for (int i = 0; i < c; ++i)
			for (int j = 0; j < r; ++j)
				result[i][j] = mat[j][i];
		return result;
	}

	public static String repeatString(String s, long count) {
		StringBuilder sb = new StringBuilder();
		for (long i = 0; i < count; ++i) {
			sb.append(s);
		}
		return sb.toString();
	}
}

class Treap<K extends Comparable<? super K>, V> {
	
	Treap() {
		nullNode = new TreapNode<K, V>();
		nullNode.left = nullNode.right = nullNode;
		nullNode.priority = Integer.MAX_VALUE;
		rootNode = nullNode;
	}
	
	public V put(K key, V value) {
		PutResult<K, V> putResult = putHelp(rootNode, key, value);
		rootNode = putResult.newNode;
		return putResult.originalValue;
	}
	
	public V get(K key) {
		TreapNode<K, V> currentNode = rootNode;
		while(currentNode != nullNode && currentNode.key.compareTo(key) != 0) {
			if(key.compareTo(currentNode.key) < 0) {
				currentNode = currentNode.left;
			} else {
				currentNode = currentNode.right;
			}
		}
		
		if(currentNode == nullNode) {
			return null;
		} else {
			return currentNode.value;
		}
	}
	
	public V remove(K key) {
		V result = get(key);
		if(result != null) {
			rootNode = removeHelp(rootNode, key);
		}
		return result;
	}
	
	public K select(int rank) {
		if(rank >= size() || rank < 0) {
			return null;
		}
		TreapNode<K, V> currentNode = rootNode;
		while(rank != currentNode.left.size) {
			if(rank < currentNode.left.size) {
				currentNode = currentNode.left;
			} else {
				rank -= currentNode.left.size + 1;
				currentNode = currentNode.right;
			}
		}
		
		return currentNode.key;
	}
	
	public int rank(K key) {
		if(rootNode == nullNode) {
			return -1;
		}
		int result = rootNode.left.size;
		TreapNode<K, V> currentNode = rootNode;
		while(currentNode != nullNode && currentNode.key.compareTo(key) != 0) {
			if(key.compareTo(currentNode.key) < 0) {
				result -= currentNode.left.right.size + 1;
				currentNode = currentNode.left;
			} else {
				result += currentNode.right.left.size + 1;
				currentNode = currentNode.right;
			}
		}
		
		if(currentNode == nullNode) {
			return -1;
		} else {
			return result;
		}
	}
	
	public void clear() {
		rootNode = nullNode;
	}
	
	public int size() {
		return rootNode.size;
	}
	
	private static class TreapNode<K, V> {
		public K key;
		public V value;
		public int size;
		public int priority;
		TreapNode<K, V> left, right;
	}
	
	private static class PutResult<K, V> {
		public TreapNode<K, V> newNode;
		public V originalValue;
	}
	
	private PutResult<K, V> putHelp(TreapNode<K, V> node, K key, V value) {
		if(node == nullNode) {
			PutResult<K, V> result = new PutResult<K, V>();
			result.newNode = new TreapNode<K, V>();
			result.newNode.key = key;
			result.newNode.value = value;
			result.newNode.size = 1;
			result.newNode.priority = randomPriority.nextInt(Integer.MAX_VALUE);
			result.newNode.left = result.newNode.right = nullNode;
			return result;
		} else if(key.compareTo(node.key) == 0) {
			PutResult<K, V> result = new PutResult<K, V>();
			result.originalValue = node.value;
			node.value = value;
			result.newNode = node;
			return result;
		} else if(key.compareTo(node.key) < 0) {
			PutResult<K, V> result = putHelp(node.left, key, value);
			node.left = result.newNode;
			if(result.originalValue == null) {
				++node.size;
				if(node.left.priority < node.priority) {
					node = rightRotate(node);
				}
			}
			result.newNode = node;
			return result;
		} else {
			PutResult<K, V> result = putHelp(node.right, key, value);
			node.right = result.newNode;
			if(result.originalValue == null) {
				++node.size;
				if(node.right.priority < node.priority) {
					node = leftRotate(node);
				}
			}
			result.newNode = node;
			return result;
		}
	}
	
	private TreapNode<K, V> removeHelp(TreapNode<K, V> node, K key) {
		if(key.compareTo(node.key) == 0) {
			node = removeHelp2(node);
		} else if(key.compareTo(node.key) < 0) {
			--node.size;
			node.left = removeHelp(node.left, key);
		} else {
			--node.size;
			node.right = removeHelp(node.right, key);
		}
		return node;
	}
	
	private TreapNode<K, V> removeHelp2(TreapNode<K, V> node) {
		if(node.left == nullNode && node.right == nullNode) {
			return nullNode;
		}
		
		if(node.left.priority < node.right.priority) {
			node = rightRotate(node);
			--node.size;
			node.right = removeHelp2(node.right);
		} else {
			node = leftRotate(node);
			--node.size;
			node.left = removeHelp2(node.left);
		}
		return node;
	}
	
	private TreapNode<K, V> leftRotate(TreapNode<K, V> node) {
		TreapNode<K, V> result = node.right;
		node.right = result.left;
		result.left = node;
		result.size = node.size;
		node.size -= 1 + result.right.size;
		return result;
	}
	
	private TreapNode<K, V> rightRotate(TreapNode<K, V> node) {
		TreapNode<K, V> result = node.left;
		node.left = result.right;
		result.right = node;
		result.size = node.size;
		node.size -= 1 + result.left.size;
		return result;
	}
	
	private TreapNode<K, V> nullNode;
	private TreapNode<K, V> rootNode;
	private Random randomPriority = new Random();
}