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

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
from functools import reduce

def sol(l):
	if not 'X' in l:
		return '0'
	l = l.replace('O', '0').replace('X', '1')
	res = ['%ix%i' % (12 // i, i) for i in (12, 6, 4, 3, 2, 1) if reduce(lambda x, y: x & y, [int(l[i * j:i * j + i], 2) for j in range(12 // i)], -1)]
	return '%i %s' % (len(res), ' '.join(res))
n = int(input())
print('\n'.join([sol(input()) for i in range(n)]))


le = int(input())
for _ in range(le):
	str1 = input()
	count = 0
	arr = [1, 2, 3, 4, 6, 12]
	arr1 = []
	for num in arr:
		flag = False
		i = 12 // num
		for j in range(i):
			if str1[j] == 'X':
				flag = True
				z = j
				while z < 12:
					if str1[z] != 'X':
						flag = False
						break
					z += i
				if flag:
					break
		if flag:
			count += 1
			arr1.append(str(str(num) + 'x' + str(12 // num)))
	print(count, end=' ')
	for j in arr1:
		print(j, end=' ')
	print('\t')


T = int(input())
for t in range(T):
	s = input()
	ans = 0
	L = []
	for i in [1, 2, 3, 4, 6, 12]:
		x = i
		y = 12 // x
		E = []
		for j in range(12):
			if j % y == 0:
				E.append('')
			E[-1] += s[j]
		for j in range(y):
			c = 0
			for z in range(i):
				if E[z][j] == 'X':
					c += 1
			if c == i:
				ans += 1
				L.append(i)
				break
	print(ans, end=' ')
	for item in L:
		print(item, end='x')
		print(12 // item, end=' ')
	print()


t = int(input())
for _ in range(t):
	s = input().strip()
	S = [a == 'X' for a in s]
	ans = []
	if s == 'O' * 12:
		print(0)
	elif s == 'X' * 12:
		print('6 1x12 2x6 3x4 4x3 6x2 12x1')
	else:
		ans.append('1x12')
		s1 = [S[6 * i] for i in range(0, 2)]
		s2 = [S[6 * i + 1] for i in range(0, 2)]
		s3 = [S[6 * i + 2] for i in range(0, 2)]
		s4 = [S[6 * i + 3] for i in range(0, 2)]
		s5 = [S[6 * i + 4] for i in range(0, 2)]
		s6 = [S[6 * i + 5] for i in range(0, 2)]
		d2 = any([all(s1), all(s2), all(s3), all(s4), all(s5), all(s6)])
		if d2:
			ans.append('2x6')
		s1 = [S[4 * i] for i in range(0, 3)]
		s2 = [S[4 * i + 1] for i in range(0, 3)]
		s3 = [S[4 * i + 2] for i in range(0, 3)]
		s4 = [S[4 * i + 3] for i in range(0, 3)]
		d3 = any([all(s1), all(s2), all(s3), all(s4)])
		if d3:
			ans.append('3x4')
		if d2:
			s1 = [S[3 * i] for i in range(0, 4)]
			s2 = [S[3 * i + 1] for i in range(0, 4)]
			s3 = [S[3 * i + 2] for i in range(0, 4)]
			d4 = any([all(s1), all(s2), all(s3)])
			if d4:
				ans.append('4x3')
			if d3:
				s1 = [S[2 * i] for i in range(0, 6)]
				s2 = [S[2 * i + 1] for i in range(0, 6)]
				d6 = any([all(s1), all(s2)])
				if d6:
					ans.append('6x2')
		print('{} {}'.format(len(ans), ' '.join(ans)))


t = int(input())
for _ in range(t):
	s = input()
	b = []
	for n in [1, 2, 3, 4, 6, 12]:
		m = 12 // n
		for j in range(m):
			if s[j::m] == 'X' * n:
				b += [(n, m)]
				break
	print(len(b), ' '.join((str(x) + 'x' + str(y) for (x, y) in b)))


n = int(input())
for i in range(n):
	a = input()
	c = 0
	p = ''
	if 'XXXXXXXXXXXX' == a:
		print('6 1x12 2x6 3x4 4x3 6x2 12x1')
		continue
	if 'X' in a:
		p = p + '1x12'
		c += 1
		if 'XX' == a[0] + a[6] or 'XX' == a[1] + a[7] or 'XX' == a[2] + a[8] or ('XX' == a[3] + a[9]) or ('XX' == a[4] + a[10]) or ('XX' == a[5] + a[11]):
			c += 1
			p += ' 2x6'
		if 'XXX' == a[0] + a[4] + a[8] or 'XXX' == a[1] + a[5] + a[9] or 'XXX' == a[2] + a[6] + a[10] or ('XXX' == a[3] + a[7] + a[11]):
			p += ' 3x4'
			c += 1
		if 'XXXX' == a[0] + a[3] + a[6] + a[9] or 'XXXX' == a[1] + a[4] + a[7] + a[10] or 'XXXX' == a[2] + a[5] + a[8] + a[11]:
			c += 1
			p += ' 4x3'
		if 'XXXXXX' == a[0] + a[2] + a[4] + a[6] + a[8] + a[10] or 'XXXXXX' == a[1] + a[3] + a[5] + a[7] + a[9] + a[11]:
			c += 1
			p += ' 6x2'
		print(c, p)
	else:
		print(0)


t = int(input())
ans = [[] for i in range(t)]
for i in range(t):
	s = input()
	for a in range(1, 13):
		if 12 % a != 0:
			continue
		b = 12 // a
		c = [[] for h in range(b)]
		for h in range(b):
			for k in range(a):
				c[h].append(s[k * b + h])
		if a == 3:
			a = 3
		T = True
		for h in range(b):
			if T:
				ok = True
				for k in range(a):
					if c[h][k] == 'O':
						ok = False
				if ok:
					ans[i].append([a, b])
					T = False
					break
for i in range(t):
	print(len(ans[i]), end=' ')
	for z in ans[i]:
		print(z[0], end='')
		print('x', end='')
		print(z[1], end=' ')
	print()


def read_ints():
	return map(int, input().strip().split())
(t,) = read_ints()
for _ in range(t):
	x = input()
	correct = []
	for a in [1, 2, 3, 4, 6, 12]:
		cor = False
		for c in range(0, 12 // a):
			s = set(x[c::12 // a])
			if len(s) == 1 and 'X' in s:
				cor = True
				break
		if cor == True:
			correct.append('{}x{}'.format(a, 12 // a))
	print(len(correct), ' '.join(correct))


q = [12, 6, 4, 3, 2, 1]
p = {12 // i: 'X' * i for i in q}
r = {i: str(12 // i) + 'x' + str(i) for i in q}
for i in range(int(input())):
	(s, t) = ([], input())
	for j in q:
		if any((t[k::j] == p[j] for k in range(j))):
			s.append(r[j])
	print(len(s), ' '.join(s))


t = int(input())
res = []
for i in range(t):
	s = input()
	c = 0
	p = []
	for j in range(12):
		if s[j] == 'X':
			p.append('1x12')
			c += 1
			break
	for j in range(6):
		if s[j] == 'X' and s[j + 6] == 'X':
			p.append('2x6')
			c += 1
			break
	for j in range(4):
		if s[j] == 'X' and s[j + 4] == 'X' and (s[j + 8] == 'X'):
			p.append('3x4')
			c += 1
			break
	for j in range(3):
		if s[j] == 'X' and s[j + 3] == 'X' and (s[j + 6] == 'X') and (s[j + 9] == 'X'):
			p.append('4x3')
			c += 1
			break
	for j in range(2):
		if s[j] == 'X' and s[j + 2] == 'X' and (s[j + 4] == 'X') and (s[j + 6] == 'X') and (s[j + 8] == 'X') and (s[j + 10] == 'X'):
			p.append('6x2')
			c += 1
			break
	if s.count('X') == 12:
		p.append('12x1')
		c += 1
	if c == 0:
		res.append(c)
	else:
		res.append('{} {}'.format(c, ' '.join(p)))
for i in res:
	print(i)


t = int(input())
pairs = [(1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)]
for _ in range(t):
	a = list(input())
	a = [ord(i) - ord('O') for i in a]
	ans = []
	for i in pairs:
		for j in range(i[1]):
			if all(a[j::i[1]]):
				ans.append(i)
				break
	an = ''
	an += str(len(ans)) + ' '
	for i in ans:
		an += str(i[0]) + 'x' + str(i[1]) + ' '
	print(an)


n = int(input())
while n:
	s = input()
	cases = [[1, 12], [2, 6], [3, 4], [4, 3], [6, 2], [12, 1]]
	anst = list()
	for t in range(6):
		for i in range(cases[t][1]):
			f = False
			if s[i] == 'X':
				f = True
				for j in range(1, cases[t][0]):
					aux = s[i + j * cases[t][1]] == 'X'
					f = aux & f
				if f:
					anst.append('%dx%d' % (cases[t][0], cases[t][1]))
					break
				else:
					f = False
	print(len(anst), end=' ')
	for i in range(len(anst)):
		print(anst[i], end=' ')
	print()
	n -= 1


for i in range(int(input())):
	s = input()
	c = 0
	for i in s:
		if i == 'X':
			c += 1
	if c == 0:
		print(0)
	elif c == 12:
		print('6 1x12 2x6 3x4 4x3 6x2 12x1')
	else:
		(c, l) = (1, [1, 0, 0, 0, 0, 0])
		if s[0] == 'X' and s[6] == 'X' or (s[1] == 'X' and s[7] == 'X') or (s[2] == 'X' and s[8] == 'X') or (s[3] == 'X' and s[9] == 'X') or (s[4] == 'X' and s[10] == 'X') or (s[5] == 'X' and s[11] == 'X'):
			l[1] = 1
			c += 1
		if s[0] == 'X' and s[4] == 'X' and (s[8] == 'X') or (s[1] == 'X' and s[5] == 'X' and (s[9] == 'X')) or (s[2] == 'X' and s[6] == 'X' and (s[10] == 'X')) or (s[3] == 'X' and s[7] == 'X' and (s[11] == 'X')):
			l[2] = 1
			c += 1
		if s[0] == 'X' and s[3] == 'X' and (s[6] == 'X') and (s[9] == 'X') or (s[1] == 'X' and s[4] == 'X' and (s[7] == 'X') and (s[10] == 'X')) or (s[2] == 'X' and s[5] == 'X' and (s[8] == 'X') and (s[11] == 'X')):
			l[3] = 1
			c += 1
		if s[0] == 'X' and s[2] == 'X' and (s[4] == 'X') and (s[6] == 'X') and (s[8] == 'X') and (s[10] == 'X') or (s[1] == 'X' and s[3] == 'X' and (s[5] == 'X') and (s[7] == 'X') and (s[9] == 'X') and (s[11] == 'X')):
			l[4] = 1
			c += 1
		print(c, '1x12', end=' ')
		if l[1] == 1:
			print('2x6', end=' ')
		if l[2] == 1:
			print('3x4', end=' ')
		if l[3] == 1:
			print('4x3', end=' ')
		if l[4] == 1:
			print('6x2', end=' ')
		print()


n = int(input())
a = [2, 3, 4, 6]
for i in range(n):
	s = input()
	y = []
	if 'X' in s:
		y.append('1x12')
	for j in a:
		for k in range(12 // j):
			x = ''
			for c in range(j):
				x += s[12 // j * c + k]
			if 'O' not in x:
				y.append(str(j) + 'x' + str(12 // j))
				break
	if 'O' not in s:
		y.append('12x1')
	print(len(y), end=' ')
	print(*y, sep=' ')


testcases = int(input())
while True:
	testcases -= 1
	if testcases < 0:
		break
	cards = list(input())
	possibilities = [[True, 1, 12], [True, 2, 6], [True, 3, 4], [True, 4, 3], [True, 6, 2], [True, 12, 1]]
	possible = 6
	for k in range(6):
		p = possibilities[k]
		ok = [1] * p[2]
		for i in range(12):
			if cards[i] == 'O':
				ok[i % p[2]] = 0
		if sum(ok) == 0:
			possibilities[k][0] = False
			possible -= 1
	print(possible, ' ', end='', sep='')
	for p in possibilities:
		if p[0]:
			print(' ', p[1], 'x', p[2], end='', sep='')
	print()


import sys

def main():
	n = int(input())
	list = []
	for i in range(0, n):
		list.append(input())
	for l in list:
		rez = []
		for i in range(1, 13):
			if 12 % i == 0:
				a = i
				b = 12 // i
				parts = [l[k:k + b] for k in range(0, 12, b)]
				for k in range(0, b):
					flag = True
					for p in parts:
						if p[k] == 'O':
							flag = False
							break
					if flag:
						rez.append(str(a) + 'x' + str(b))
						break
		sys.stdout.write(str(len(rez)) + ' ')
		for i in rez:
			sys.stdout.write(i + ' ')
		print()
main()


t = int(input())
for i in range(t):
	s = input()
	lst = []
	if 'X' in s:
		lst.append('1x12')
	for i in range(6):
		if s[i] == s[i + 6] == 'X':
			lst.append('2x6')
			break
	for i in range(4):
		if s[i] == s[i + 4] == s[i + 8] == 'X':
			lst.append('3x4')
			break
	for i in range(3):
		if s[i] == s[i + 3] == s[i + 6] == s[i + 9] == 'X':
			lst.append('4x3')
			break
	for i in range(2):
		if s[i] == s[i + 2] == s[i + 4] == s[i + 6] == s[i + 8] == s[i + 10] == 'X':
			lst.append('6x2')
			break
	if 'O' not in s:
		lst.append('12x1')
	print(len(lst), *lst)


t = int(input())
dividers = [1, 2, 3, 4, 6, 12]
for test in range(t):
	s = input()
	ans = []
	for k in dividers:
		for j in range(12 // k):
			cnt = 0
			for i in range(k):
				if s[i * (12 // k) + j] == 'X':
					cnt += 1
			if cnt == k:
				ans.append(str(k) + 'x' + str(12 // k))
				break
	print(len(ans), ' '.join(map(str, ans)))


for _ in range(int(input())):
	s = input().strip()
	sol = []
	l = [1, 2, 3, 4, 6, 12]
	for i in l:
		for j in range(0, i):
			if set(s[j::i]) == set('X'):
				sol.append((12 / i, i))
				break
	sol.sort()
	if len(sol) > 0:
		print(len(sol), end=' ')
		for x in sol:
			print('%dx%d' % (x[0], x[1]), sep=' ', end=' ')
	else:
		print(0, end='')
	print()


t = int(input())
for i in range(t):
	s = input().strip()
	cnt = 0
	ans = []
	for b in [1, 2, 3, 4, 6, 12]:
		List = []
		a = 12 // b
		for begin in range(b):
			column = ''
			j = begin
			while j < 12:
				column += s[j]
				j += b
			List.append(column)
		if 'X' * a in List:
			cnt += 1
			ans.append((a, b))
	print(cnt, end=' ')
	for pair in sorted(ans):
		print('x'.join(map(str, pair)), end=' ')
	print()


tests = int(input())
while tests > 0:
	field = input()
	variants = []
	for (lines, columns) in ((1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)):

		def x_column(column):
			global field, columns, lines
			for line in range(lines):
				if field[column + columns * line] == 'O':
					return False
			return True
		for column in range(columns):
			if x_column(column):
				variants.append(str(lines) + 'x' + str(columns))
				break
	print(len(variants), *variants)
	tests -= 1


liste_a = (1, 2, 3, 4, 6, 12)
liste_results = []

def process(essai):
	global liste_results
	liste_av = [0]
	for a in liste_a:
		b = 12 // a
		for r in range(b):
			if essai[r::b] == 'X' * a:
				liste_av[0] += 1
				liste_av.append('{}x{}'.format(a, b))
				break
	liste_av[0] = str(liste_av[0])
	liste_results.append(liste_av)
t = int(input())
for k in range(t):
	essai = input()
	process(essai)
for s in liste_results:
	print(*s)


def main():
	res = []
	for _ in range(int(input())):
		(l, s) = ([None], input())
		for (b, sig) in ((12, '1x12'), (6, '2x6'), (4, '3x4'), (3, '4x3'), (2, '6x2'), (1, '12x1')):
			if not all((s[_::b].count('O') for _ in range(b))):
				l.append(sig)
		l[0] = str(len(l) - 1)
		res.append(' '.join(l))
	print('\n'.join(res))
main()


def is_possible(request, a):
	b = 12 // a
	for i in range(b):
		if 'O' not in [request[i + j * b] for j in range(a)]:
			return True
	return False

def solve(request):
	possible_ways = [1, 2, 3, 4, 6, 12]
	count_ways = 0
	ways = []
	for i in possible_ways:
		if is_possible(request, i):
			count_ways += 1
			ways += ['%dx%d' % (i, 12 // i)]
	ways = [str(count_ways)] + ways
	return ' '.join(ways)

def main():
	n = int(input())
	for _ in range(n):
		print(solve(input()))
main()


from collections import defaultdict

def main():
	t = int(input())
	for _ in range(t):
		s = input()
		ans_list = []
		for a in [1, 2, 3, 4, 6, 12]:
			b = 12 // a
			found = False
			for i in range(b):
				if 'O' not in [s[j] for j in range(i, 12, b)]:
					found = True
					break
			if found:
				ans_list.append('{0}x{1}'.format(a, b))
		print(len(ans_list), *ans_list, sep=' ')
main()


n = int(input())
ab = [12, 6, 4, 3, 2, 1]
lst = [list(input()) for i in range(n)]
res = [[0] for i in range(n)]
for pr in range(n):
	for elem in ab:
		for i in range(elem):
			x = 1
			for j in range(0, 12, elem):
				if lst[pr][i + j] == 'O':
					x = 0
			if x == 1 and str(12 // elem) + 'x' + str(elem) not in res[pr]:
				res[pr][0] += 1
				res[pr].append(str(12 // elem) + 'x' + str(elem))
for i in range(len(res)):
	print(' '.join(map(str, res[i])))


def f(x):
	return str(12 // x) + 'x' + str(x)
a = [12, 6, 4, 3, 2, 1]
t = int(input())
for i in range(t):
	ans = []
	s = input()
	for y in a:
		for j in range(y):
			if s[j::y].count('X') == 12 // y:
				ans += [y]
				break
	print(len(ans), ' '.join(list(map(f, ans))))


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations
from math import gcd, floor, inf
from bisect import bisect_right, bisect_left

def solve(s, ln):
	N = len(s)
	if N % ln != 0:
		return False
	dv = N // ln
	mx = []
	for i in range(0, N, dv):
		mx.append(list(s[i:i + dv]))
	trans = [[mx[i][j] for i in range(len(mx))] for j in range(len(mx[0]))]
	for row in trans:
		if 'O' not in row:
			return True
	return False
cases = int(input())
for _ in range(cases):
	s = input()
	ans_num = 0
	ans_str = []
	for i in range(1, 13):
		if solve(s, i):
			ans_num += 1
			ans_str.append(str(i) + 'x' + str(len(s) // i))
	print(ans_num, *ans_str)


def q400a():
	n = int(input())
	for i in range(n):
		q400a_process_case(input())

def q400a_process_case(case):
	outputs = []
	if 'X' in case:
		outputs.append('1x12 ')
	if check_one_shape(case, 6):
		outputs.append('2x6 ')
	if check_one_shape(case, 4):
		outputs.append('3x4 ')
	if check_one_shape(case, 3):
		outputs.append('4x3 ')
	if check_one_shape(case, 2):
		outputs.append('6x2 ')
	if case == 'XXXXXXXXXXXX':
		outputs.append('12x1')
	if len(outputs) == 0:
		print(0)
	else:
		str1 = '%d ' + '%s ' * len(outputs)
		print(str1 % (len(outputs), *outputs))

def check_one_shape(case, shape):
	for i in range(shape):
		correct = 'X' * (12 // shape)
		if case[int(i):int(12):int(shape)] == correct:
			return True
	return False
q400a()


for i in range(int(input())):
	s = input()
	count = s.count('X')
	if count == 0:
		print(0)
	elif count == 12:
		print('6 1x12 2x6 3x4 4x3 6x2 12x1')
	else:
		lst = []
		if count >= 6:
			for i in range(2):
				if s[i] == s[i + 2] == s[i + 4] == s[i + 6] == s[i + 8] == s[i + 10] == 'X':
					lst.append('6x2')
					break
		if count >= 4:
			for i in range(3):
				if s[i] == s[i + 3] == s[i + 6] == s[i + 9] == 'X':
					lst.append('4x3')
					break
		if count >= 3:
			for i in range(4):
				if s[i] == s[i + 4] == s[i + 8] == 'X':
					lst.append('3x4')
					break
		if count >= 2:
			for i in range(6):
				if s[i] == s[i + 6] == 'X':
					lst.append('2x6')
					break
		if count >= 1:
			lst.append('1x12')
		lst.sort()
		print(str(len(lst)) + ' ' + ' '.join(lst))


t = int(input().strip())
for i in range(t):
	s = input()
	ans = []
	for h in [x for x in range(1, 13) if 12 % x == 0]:
		good = False
		w = 12 // h
		for k in range(w):
			ok = True
			for l in range(h):
				if s[l * w + k] != 'X':
					ok = False
			if ok:
				good = True
		if good:
			ans.append(str(h) + 'x' + str(w))
	print(str(len(ans)) + ' ' + ' '.join(ans))


T = int(input())
while T >= 1:
	T -= 1
	a = input()
	list = []
	for i in range(1, 13):
		if 12 % i == 0:
			l = 12 // i
			for j in range(0, l):
				for k in range(0, i):
					if a[k * l + j] != 'X':
						break
				else:
					break
			else:
				continue
			list.append(i)
	print(len(list), end=' ')
	for i in range(0, len(list)):
		print(str(list[i]) + 'x' + str(12 // list[i]), end=' ')
	print()


As = [1, 2, 3, 4, 6, 12]
C = int(input())
for c in range(C):
	S = list(input())
	ans = []
	for a in As:
		b = 12 // a
		fre = [0] * 12
		for (i, q) in enumerate(S):
			if q == 'X':
				fre[i % a] += 1
		if max(fre) >= b:
			ans += [a]
	print(len(ans), end=' ')
	ans.sort(reverse=True)
	for a in ans:
		print(str(12 // a) + 'x' + str(a), end=' ')
	print()


t = eval(input())
c = 1
while c <= t:
	a = str(input())
	if a == 'XXXXXXXXXXXX':
		print('6 1x12 2x6 3x4 4x3 6x2 12x1')
	elif a == 'OOOOOOOOOOOO':
		print(0)
	else:
		s = ['1x12']
		i = 0
		while i < 6:
			if a[i] == 'X' and a[i + 6] == 'X':
				s = s + ['2x6']
				break
			i += 1
		i = 0
		while i < 4:
			if a[i] == 'X' and a[i + 4] == 'X' and (a[i + 8] == 'X'):
				s = s + ['3x4']
				break
			i += 1
		i = 0
		while i < 3:
			if a[i] == 'X' and a[i + 3] == 'X' and (a[i + 6] == 'X') and (a[i + 9] == 'X'):
				s = s + ['4x3']
				break
			i += 1
		i = 0
		while i < 2:
			if a[i] == 'X' and a[i + 2] == 'X' and (a[i + 4] == 'X') and (a[i + 6] == 'X') and (a[i + 8] == 'X') and (a[i + 10] == 'X'):
				s = s + ['6x2']
				break
			i += 1
		print(len(s), ' '.join(map(str, s)))
	c += 1


def solve(matriz):
	n = len(matriz)
	m = len(matriz[0])
	for j in range(m):
		curr = True
		for i in range(n):
			if matriz[i][j] == 'O':
				curr = False
				break
		if curr:
			return True
	return False

def gera_matriz(s, e):
	ans = []
	for i in range(0, len(s), e[1]):
		ans.append(s[i:i + e[1]])
	return ans
t = int(input())
pos = [(1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)]
for i in range(t):
	s = input()
	ans = []
	for e in pos:
		matriz = gera_matriz(s, e)
		if solve(matriz):
			ans.append(e)
	tmp = []
	for e in ans:
		tmp.append(str(e[0]) + 'x' + str(e[1]))
	print(f"{len(ans)} {' '.join(tmp)}")


num = int(input())
strings = ['1x12', '2x6', '3x4', '4x3', '6x2', '12x1']
for i in range(num):
	lista = [0] * 6
	row = input()
	for j in range(12):
		if row[j] == 'X':
			lista[0] = 1
			break
	for j in range(6):
		if row[j] == row[j + 6] == 'X':
			lista[1] = 1
			break
	for j in range(4):
		if row[j] == 'X' and row[j + 4] == 'X' and (row[j + 8] == 'X'):
			lista[2] = 1
			break
	for j in range(3):
		if row[j] == row[j + 3] == row[j + 6] == row[j + 9] == 'X':
			lista[3] = 1
			break
	for j in range(2):
		if row[j] == row[j + 2] == row[j + 4] == row[j + 6] == row[j + 8] == row[j + 10] == 'X':
			lista[4] = 1
			break
	equalsX = True
	for j in range(12):
		if row[j] != 'X':
			equalsX = False
	if equalsX:
		lista[5] = 1
	total = 0
	saida = ''
	for j in range(6):
		if lista[j]:
			total += 1
			saida += strings[j] + ' '
	print((str(total) + ' ' + saida).strip())


import math
import math
from collections import defaultdict, Counter
from itertools import permutations

def fact(n):
	return 1 if n == 1 or n == 0 else n * fact(n - 1)

def prime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def inp():
	l = list(map(int, input().split()))
	return l

def main():
	for _ in range(int(input())):
		s = input()
		ll = []
		l = [12, 6, 4, 3, 2, 1]
		if 'X' in s:
			ll.append(12)
		for i in range(1, len(l)):
			m = []
			for j in range(0, 12 // l[i]):
				m.append(s[j * l[i]:(j + 1) * l[i]])
			for k in range(len(m[0])):
				for p in range(len(m)):
					if m[p][k] == 'X':
						pass
					else:
						break
				else:
					ll.append(l[i])
					break
		print(len(ll), end=' ')
		for i in ll:
			print(str(12 // i) + str('x') + str(i), end=' ')
		print()
import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)


testcases = int(input())
for k in range(testcases):
	juego = list(input())
	casos = []
	f = True
	e = False
	d = False
	c = False
	b = False
	a = False
	ctr = 0
	result = ''
	for k in range(6):
		if juego[k] == 'X' and juego[k + 6] == 'X':
			b = True
			break
	for k in range(4):
		if juego[k] == 'X' and juego[k + 4] == 'X' and (juego[k + 8] == 'X'):
			c = True
			break
	for k in range(3):
		if juego[k] == 'X' and juego[k + 3] == 'X' and (juego[k + 6] == 'X') and (juego[k + 9] == 'X'):
			d = True
			break
	for k in range(2):
		if juego[k] == 'X' and juego[k + 2] == 'X' and (juego[k + 4] == 'X') and (juego[k + 6] == 'X') and (juego[k + 8] == 'X') and (juego[k + 10] == 'X'):
			e = True
			break
	for k in range(12):
		if juego[k] == 'X':
			a = True
		if juego[k] == 'O':
			f = False
	if a:
		result += ' 1x12'
		ctr += 1
	if b:
		result += ' 2x6'
		ctr += 1
	if c:
		result += ' 3x4'
		ctr += 1
	if d:
		result += ' 4x3'
		ctr += 1
	if e:
		result += ' 6x2'
		ctr += 1
	if f:
		result += ' 12x1'
		ctr += 1
	print(str(ctr) + result)


n = int(input())
arr = [12, 6, 4, 3, 2, 1]
for i in range(n):
	x = input()
	final = ''
	c = 0
	for k in arr:
		ans = [0] * 12
		for j in range(0, len(x)):
			if x[j] == 'X':
				ans[j % k] += 1
		if k == 12:
			for j in ans:
				if j == 1:
					c += 1
					final += ' 1x12'
					break
		if k == 6:
			for j in ans:
				if j == 2:
					c += 1
					final += ' 2x6'
					break
		if k == 4:
			for j in ans:
				if j == 3:
					c += 1
					final += ' 3x4'
					break
		if k == 3:
			for j in ans:
				if j == 4:
					c += 1
					final += ' 4x3'
					break
		if k == 2:
			for j in ans:
				if j == 6:
					c += 1
					final += ' 6x2'
					break
		if k == 1:
			for j in ans:
				if j == 12:
					c += 1
					final += ' 12x1'
					break
	print(f'{c}{final}')


N = 12
al = [a for a in range(1, N + 1) if N % a == 0]

def w(s, a):
	for c in range(N // a):
		if s[c::N // a] == 'X' * a:
			return True
	return False

def tc(s):
	val = [str(a) + 'x' + str(N // a) for a in al if w(s, a)]
	print(len(val), ' '.join(val))
for t in range(int(input())):
	tc(input())


divisions = [(1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)]

def check(s, a, b):
	for i in range(b):
		if s[i::b] == 'X' * a:
			return True
	return False

def solve():
	s = input()
	ans = []
	for division in divisions:
		if check(s, *division):
			ans.append(str(division[0]) + 'x' + str(division[1]))
	print(len(ans), ' '.join(ans))
t = int(input())
for i in range(t):
	solve()


n = int(input())
for i in range(n):
	s = input()
	ans = []
	for j in [1, 2, 3, 4, 6, 12]:
		k = 12 // j
		for i in range(k):
			if s[i::k] == 'X' * j:
				ans += [(j, k)]
				break
	print(len(ans), ' '.join((str(x) + 'x' + str(y) for (x, y) in ans)))


def fun():
	num = input()
	slon = []
	if num.count('X') > 0:
		slon.append('1x12')
	if num[0] == 'X' and num[6] == 'X' or (num[1] == 'X' and num[7] == 'X') or (num[2] == 'X' and num[8] == 'X') or (num[3] == 'X' and num[9] == 'X') or (num[4] == 'X' and num[10] == 'X') or (num[5] == 'X' and num[11] == 'X'):
		slon.append('2x6')
	if num[0] == 'X' and num[4] == 'X' and (num[8] == 'X') or (num[1] == 'X' and num[5] == 'X' and (num[9] == 'X')) or (num[2] == 'X' and num[6] == 'X' and (num[10] == 'X')) or (num[3] == 'X' and num[7] == 'X' and (num[11] == 'X')):
		slon.append('3x4')
	if num[0] == 'X' and num[3] == 'X' and (num[6] == 'X') and (num[9] == 'X') or (num[1] == 'X' and num[4] == 'X' and (num[7] == 'X') and (num[10] == 'X')) or (num[2] == 'X' and num[5] == 'X' and (num[8] == 'X') and (num[11] == 'X')):
		slon.append('4x3')
	if num[0] == 'X' and num[2] == 'X' and (num[4] == 'X') and (num[6] == 'X') and (num[8] == 'X') and (num[10] == 'X') or (num[1] == 'X' and num[3] == 'X' and (num[5] == 'X') and (num[7] == 'X') and (num[9] == 'X') and (num[11] == 'X')):
		slon.append('6x2')
	if num.count('X') == 12:
		slon.append('12x1')
	return slon
t = int(input())
for i in range(t):
	num = fun()
	print(len(num), end=' ')
	print(*num)


t = int(input())
for _ in range(t):
	s = input()
	a1 = [1, 2, 3, 4, 6, 12]
	ans = []
	for a in a1:
		b = int(12 / a)
		for i in range(b):
			flag = True
			for j in range(a):
				if s[b * j + i] != 'X':
					flag = False
			if flag == True:
				ans.append(a)
				break
	print(len(ans), end=' ')
	for i in ans:
		s = str(i) + 'x' + str(int(12 / i))
		print(s, end=' ')
	print()


t = int(input())
for i in range(t):
	s = input()
	ans = []
	for a in range(1, 13):
		if 12 % a == 0:
			b = 12 // a
			ok = False
			for i in range(0, b):
				f = True
				for j in range(i, len(s), b):
					if s[j] != 'X':
						f = False
				if f:
					ok = True
			if ok:
				ans.append([a, b])
	if len(ans):
		print(len(ans), end=' ')
	else:
		print(0)
	for i in range(len(ans)):
		if i < len(ans) - 1:
			print(ans[i][0], ans[i][1], sep='x', end=' ')
		else:
			print(ans[i][0], ans[i][1], sep='x')


for _ in range(int(input())):
	s = input()
	s = list(s)
	n = len(s)
	ans = []
	flag1 = 0
	flag2 = 0
	for i in s:
		if i == 'X':
			flag1 = 1
		if i == 'O':
			flag2 = 1
	if flag1 == 1:
		ans.append((1, 12))
	if flag2 != 1:
		ans.append((12, 1))
	flag1 = 0
	flag2 = 0
	for i in range(6):
		if s[i] == 'X' and s[i + 6] == 'X':
			flag1 = 1
	if flag1 == 1:
		ans.append((2, 6))
	s1 = s[::2]
	s2 = s[1::2]
	flag1 = 0
	flag2 = 0
	for i in s1:
		if i == 'O':
			flag1 = 1
	for i in s2:
		if i == 'O':
			flag2 = 1
	if flag1 == 0 or flag2 == 0:
		ans.append((6, 2))
	s1 = s[::4]
	s2 = s[1::4]
	s3 = s[2::4]
	s4 = s[3::4]
	flag1 = 0
	flag2 = 0
	flag3 = 0
	flag4 = 0
	for i in s1:
		if i == 'O':
			flag1 = 1
	for i in s2:
		if i == 'O':
			flag2 = 1
	for i in s3:
		if i == 'O':
			flag3 = 1
	for i in s4:
		if i == 'O':
			flag4 = 1
	if flag1 == 0 or flag2 == 0 or flag3 == 0 or (flag4 == 0):
		ans.append((3, 4))
	s1 = s[::3]
	s2 = s[1::3]
	s3 = s[2::3]
	flag1 = 0
	flag2 = 0
	flag3 = 0
	for i in s1:
		if i == 'O':
			flag1 = 1
	for i in s2:
		if i == 'O':
			flag2 = 1
	for i in s3:
		if i == 'O':
			flag3 = 1
	if flag1 == 0 or flag2 == 0 or flag3 == 0:
		ans.append((4, 3))
	ans.sort()
	print(f'{len(ans)}', end=' ')
	for i in range(len(ans)):
		print(f'{ans[i][0]}x{ans[i][1]}', end=' ')
	print('')


def test_col(s, a, b, col):
	res = True
	for i in range(0, a):
		if s[i * b + col] != 'X':
			res = False
	return res

def test_all_cols(s, a):
	b = len(s) // a
	if a * b != len(s):
		return False
	else:
		res = False
		for i in range(0, b):
			res = res or test_col(s, a, b, i)
		return res
n = int(input())
for i in range(0, n):
	s = input()
	slen = len(s)
	cvariants = 0
	variants = ''
	for a in range(1, slen + 1):
		if test_all_cols(s, a):
			cvariants += 1
			variants += str(a) + 'x' + str(slen // a) + ' '
	print(str(cvariants), variants)


def main():
	l = int(input())
	tooutputlist = []
	frominputlist = []
	for i in range(0, l):
		frominputlist.append(input())
	for i in frominputlist:
		line = i
		c = 0
		if 'O' not in line:
			print(6, '1x12 2x6 3x4 4x3 6x2 12x1')
		elif 'X' not in line:
			print(0)
		else:
			while c < 12:
				if line[c] == 'X':
					if c < 6:
						if line[c + 6] == 'X':
							if ' 2x6' not in tooutputlist:
								tooutputlist.insert(1, ' 2x6')
					if c < 4:
						if line[c + 4] == 'X' and line[c + 8] == 'X':
							if ' 3x4' not in tooutputlist:
								tooutputlist.insert(2, ' 3x4')
					if c < 3:
						if line[c + 3] == 'X' and line[c + 6] == 'X' and (line[c + 9] == 'X'):
							if ' 4x3' not in tooutputlist:
								tooutputlist.insert(3, ' 4x3')
					if c < 2:
						if line[c + 2] == 'X' and line[c + 4] == 'X' and (line[c + 6] == 'X') and (line[c + 8] == 'X') and (line[c + 10] == 'X'):
							if ' 6x2' not in tooutputlist:
								tooutputlist.insert(4, ' 6x2')
					if ' 1x12' not in tooutputlist:
						tooutputlist.insert(0, ' 1x12')
				c += 1
			print(len(tooutputlist), end='')
			for null in tooutputlist:
				print(null, end='')
			print()
			tooutputlist.clear()
main()


t = int(input())
for i in range(t):
	n = input()
	ab = []
	if n.find('X') != -1:
		ab.append('1x12')
	for i in range(0, 6):
		if n[i] == 'X':
			if n[6 + i] == 'X':
				ab.append('2x6')
				break
	for i in range(0, 4):
		if n[i] == 'X' and n[i + 4] == 'X' and (n[i + 8] == 'X'):
			ab.append('3x4')
			break
	for i in range(0, 3):
		if n[i] == 'X' and n[i + 3] == 'X' and (n[i + 6] == 'X') and (n[i + 9] == 'X'):
			ab.append('4x3')
			break
	if n[0] == 'X' and n[2] == 'X' and (n[4] == 'X') and (n[6] == 'X') and (n[8] == 'X') and (n[10] == 'X') or (n[1] == 'X' and n[3] == 'X' and (n[5] == 'X') and (n[7] == 'X') and (n[9] == 'X') and (n[11] == 'X')):
		ab.append('6x2')
	if n.find('XXXXXXXXXXXX') != -1:
		ab.append('12x1')
	print(len(ab), end=' ')
	for i in range(len(ab)):
		print(ab[i], end=' ')
	print()


t = int(input())
for i in range(t):
	s = input()
	k = 0
	res = []
	for b in range(12, 0, -1):
		if 12 % b == 0:
			a = 12 // b
			for j in range(b):
				good = True
				for p in range(a):
					if s[j + p * b] != 'X':
						good = False
						break
				if good:
					k += 1
					res.append(12 // b)
					break
	print(k, end=' ')
	for j in range(k):
		print(res[j], 'x', 12 // res[j], sep='', end=' ')
	print()


n = int(input())
p = 0
f = True
for k in range(n):
	s = input().strip()
	ot = set()
	for i in range(1, 13):
		if i == 5 or i == 7 or i == 9 or (i == 10) or (i == 11) or (i == 8):
			continue
		for t in range(i):
			p = True
			for j in range(t, 12, i):
				if s[j] == 'O':
					p = False
			if p:
				ot.add(i)
	ot = list(reversed(sorted(list(ot))))
	print(len(ot), end=' ')
	for i in ot:
		print(str(12 // i) + 'x' + str(i), end=' ')
	print()


a = [1, 2, 3, 4, 6, 12]
for _ in [0] * int(input()):
	b = input()
	z = []
	for (r, c) in zip(a, a[::-1]):
		d = []
		for k in range(r):
			d += [b[k * c:(k + 1) * c]]
		if any((''.join(x) == 'X' * r for x in [*zip(*d)])):
			z += [f'{r}x{c}']
	print(len(z), *z)


n = int(input())
for i in range(n):
	a = input()
	ans = []
	for j in [1, 2, 3, 4, 6, 12]:
		for k in range(12 // j):
			f = 0
			for p in range(k, 12, 12 // j):
				if a[p] == 'X':
					continue
				else:
					f = 1
			if f == 0:
				ans.append('{}x{}'.format(j, 12 // j))
				break
	if len(ans) != 0:
		print(len(ans), end=' ')
		print(*ans)
	else:
		print(0)


def printPo(s):
	res = ''
	c = 0
	if s.count('X') == 0:
		print('0')
	else:
		for i in range(s.__len__()):
			if s[i] == 'X':
				c += 1
				res += ' 1x12'
				break
		for i in range(s.__len__() // 2):
			if s[i] == 'X' and s[i] == s[i + 6]:
				c += 1
				res += ' 2x6'
				break
		for i in range(s.__len__() // 3):
			if s[i] == 'X' and s[i] == s[i + 4] == s[i + 8]:
				c += 1
				res += ' 3x4'
				break
		for i in range(s.__len__() // 4):
			if s[i] == 'X' and s[i] == s[i + 3] == s[i + 6] == s[i + 9]:
				c += 1
				res += ' 4x3'
				break
		for i in range(s.__len__() // 6):
			if s[i] == 'X' and s[i] == s[i + 2] == s[i + 4] == s[i + 6] == s[i + 8] == s[i + 10]:
				c += 1
				res += ' 6x2'
				break
		if s.count('X') == 12:
			c += 1
			res += ' 12x1'
		print(c, res)
for _ in [0] * int(input()):
	printPo(input())


n = int(input())
for _ in range(n):
	mystr = input()
	answer = []
	divisibles = [1, 2, 3, 4, 6, 12]
	for i in divisibles:
		flag = 0
		for j in range(0, 12 // i):
			columnSet = set(mystr[j::12 // i])
			if len(columnSet) == 1 and 'X' in columnSet:
				flag = 1
				break
		if flag == 1:
			answer.append('{}x{}'.format(i, 12 // i))
	print(len(answer), ' '.join(answer))


n = int(input())
ar = [[1, 12], [2, 6], [3, 4], [4, 3], [6, 2], [12, 1]]
for _ in range(n):
	s = str(input())
	cou = 0
	ans = ''
	skip = False
	for it in ar:
		(a, b) = it
		skip = False
		for j in range(b):
			if skip:
				continue
			if s[j] == 'X':
				if a == 1:
					ans += f' {a}x{b}'
					cou += 1
					skip = True
				for i in range(1, a):
					if s[i * b + j] != 'X':
						break
					if i == a - 1:
						ans += f' {a}x{b}'
						cou += 1
						skip = True
	ans = f'{cou}' + ans
	print(ans)


for _ in range(int(input())):
	s = input()
	a = []
	st = 'X' * 12
	for i in s:
		if i == 'X':
			a.append('1x12')
			break
	for i in range(6):
		if s[i] == 'X' and s[i + 6] == 'X':
			a.append('2x6')
			break
	for i in range(4):
		if s[i] == 'X' and s[i + 4] == 'X' and (s[i + 8] == 'X'):
			a.append('3x4')
			break
	for i in range(3):
		if s[i] == 'X' and s[i + 3] == 'X' and (s[i + 6] == 'X') and (s[i + 9] == 'X'):
			a.append('4x3')
			break
	for i in range(2):
		if s[i] == 'X' and s[i + 2] == 'X' and (s[i + 4] == 'X') and (s[i + 6] == 'X') and (s[i + 8] == 'X') and (s[i + 10] == 'X'):
			a.append('6x2')
			break
	if st == s:
		a.append('12x1')
	print(len(a), end=' ')
	for i in a:
		print(i, end=' ')
	print('')


options = [[1, 12], [2, 6], [3, 4], [4, 3], [6, 2], [12, 1]]
t = int(input())
for _ in range(t):
	l = list(input())
	winCount = 0
	winList = []
	for i in range(6):
		option = options[i]
		for j in range(option[1]):
			co = 0
			for k in range(option[0]):
				if l[k * option[1] + j] == 'X':
					co += 1
			if co == option[0]:
				winCount += 1
				winList.append(option)
				break
	print(winCount, end=' ')
	for i in winList:
		print(*i, sep='x', end=' ')
	print()


t = int(input())
n = 12
while t > 0:
	ans = []
	t = t - 1
	s = input()
	for i in range(n):
		r = i + 1
		if n % r != 0:
			continue
		c = n // r
		flag = False
		for j in range(c):
			id = j
			ff = False
			while id < n:
				if s[id] != 'X':
					ff = True
					break
				id = id + c
			if ff == False:
				flag = True
				break
		if flag == True:
			ans.append((r, c))
	print(len(ans), end='')
	for i in range(len(ans)):
		print(' ', ans[i][0], 'x', ans[i][1], sep='', end='')
	print('')


def evaluate(origin_str):
	ans = []
	for i in [1, 2, 3, 4, 6, 12]:
		last_idx = int(12 / i)
		flags = [1 for i in range(0, last_idx)]
		if i == 1:
			flag = False
			for ch in origin_str:
				if ch == 'X':
					flag = True
			if flag:
				ans.append([i, last_idx])
		else:
			for j in range(0, last_idx):
				tmp = []
				k = j - last_idx
				for x in range(0, i):
					k += last_idx
					tmp.append(k)
				for l in tmp:
					ch = origin_str[l]
					if ch != 'X':
						flags[j] = 0
			if sum(flags) != 0:
				ans.append([i, last_idx])
	s = ''
	for a in ans:
		s += str(a[0]) + 'x' + str(a[1]) + ' '
	print(str(len(ans)) + ' ' + s)

def main():
	n = int(input())
	for i in range(0, n):
		evaluate(input())
main()


for _ in range(int(input())):
	s = input()
	ans = 0
	st = []
	for i in range(1, 13):
		if 12 % i == 0:
			for j in range(0, 12 // i):
				flag = 0
				if s[j] == 'X':
					for k in range(j + 12 // i, 12, 12 // i):
						if s[k] != 'X':
							flag = 1
							break
				else:
					continue
				if flag == 0:
					st.append(str(i) + 'x' + str(12 // i))
					ans += 1
					break
	if ans == 0:
		print(0)
	else:
		print(ans, end=' ')
		print(*st)


def is_win(s, b):
	for j in range(b):
		if all(['X' in s[i * b + j] for i in range(12 // b)]):
			return True
	return False

def solve():
	s = input()
	bb = []
	for b in [12, 6, 4, 3, 2, 1]:
		if is_win(s, b):
			bb.append(b)
	ans = [str(len(bb))]
	for b in bb:
		ans.append(str(12 // b) + 'x' + str(b))
	print(*ans)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
c = [(1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)]
for i in range(t):
	xo = list(input())
	d = []
	b = xo.count('X')
	if b > 0:
		d.append(c[0])
	for j in c[1:5]:
		for x in range(j[1]):
			yes = True
			for k in range(j[0]):
				if xo[k * j[1] + x] != 'X':
					yes = False
					break
			if yes:
				d.append(j)
				break
	if b == 12:
		d.append(c[5])
	print(len(d), end=' ')
	for j in d:
		print(str(j[0]) + 'x' + str(j[1]), end=' ')
	print()


t = int(input())
s = []
for i in range(t):
	s.append(list(input()))
cases = []
cases.append([1, 12])
cases.append([2, 6])
cases.append([3, 4])
cases.append([4, 3])
cases.append([6, 2])
cases.append([12, 1])

def testcase(case):
	for i in case:
		if i != 'X':
			return False
	return True
o = []
for test in s:
	out = []
	for case in cases:
		found = False
		for i in range(case[1]):
			if found:
				break
			r = []
			for j in range(case[0]):
				r.append(test[i + j * case[1]])
			if testcase(r):
				out.append(case)
				found = True
	o.append(out)
for i in o:
	pr = str(len(i))
	for j in i:
		pr += ' ' + str(j[0]) + 'x' + str(j[1])
	print(pr)


def test(s):
	res = []
	for i in [[1, 12], [2, 6], [3, 4], [4, 3], [6, 2], [12, 1]]:
		a = [['O' for i in range(i[1])] for j in range(i[0])]
		for j in range(i[0]):
			for k in range(i[1]):
				a[j][k] = s[j * i[1] + k]
		if check(a):
			res.append(i)
	return res

def check(a):
	for i in range(len(a[0])):
		if not 'O' in [a[j][i] for j in range(len(a))]:
			return True
	return False
t = int(input())
for i in range(t):
	s = input().strip()
	x = test(s)
	print(len(x), end=' ')
	for j in x:
		print(j[0], 'x', j[1], sep='', end=' ')
	print()


def solve(c, n=12):
	r = set()
	for i in [1, 2, 3, 4, 6, 12]:
		win = False
		j = 12 // i
		for n in range(j):
			col = True
			for k in range(n, 12, j):
				col = col and c[k]
			win = win or col
		if win:
			r.add(i)
	return str(len(r)) + ' ' + ' '.join([str(i) + 'x' + str(12 // i) for i in r])
for _ in range(int(input())):
	board = [v == 'X' for v in input()]
	print(solve(board, 12))


factors = [12, 6, 4, 3, 2, 1]
n = int(input())
choices = []
for x in range(n):
	s = input()
	numbers = []
	for y in factors:
		rows = []
		for x in range(0, 12, y):
			rows.append(list(s[x:x + y]))
		columns = [[p[q] for p in rows] for q in range(y)]
		row = ['X' for p in range(12 // y)]
		if row in columns:
			numbers.append(y)
	choices.append(numbers)
for x in choices:
	print(len(x), end=' ')
	for y in x:
		print('%dx%d' % (12 // y, y), end=' ')
	print()


def decomp(s, n):
	m = 12 // n
	return [s[i::m] for i in range(m)]

def check(s):
	return all(map(lambda x: x == 'X', s))

def solve(s):
	res = []
	for n in [1, 2, 3, 4, 6, 12]:
		d = decomp(s, n)
		if any(map(check, d)):
			res.append(f'{n}x{12 // n}')
	print(len(res), *res)
n = int(input())
for i in range(n):
	solve(input())


fact = [2, 3, 4, 6]
n = int(input())
l1 = []
for i in range(n):
	t = input()
	l2 = []
	if t.count('X'):
		l2.append('1x12')
		for j in fact:
			for k in range(12 // j):
				flag = 0
				for l in range(k, 12, 12 // j):
					if t[l] == 'X':
						pass
					else:
						flag = 1
						break
				if flag == 0:
					l2.append(str(j) + 'x' + str(12 // j))
					break
	if t.count('X') == 12:
		l2.append('12x1')
	l1.append(l2)
for i in l1:
	print(len(i), *i)


def solve(pos):
	ans = [12]
	k = 1
	y = [6, 4, 3, 2]
	for i in y:
		if pos[0] > i:
			break
		s = i
		found = True
		for j in pos:
			if j > i:
				break
			s = j
			while s <= 12:
				if s not in pos:
					break
				s += i
			if s > 12:
				found = False
				break
		if found == False:
			ans.append(i)
			continue
	print(len(ans), end=' ')
	for i in ans:
		print('{0}x{1}'.format(12 // i, i), end=' ')
	print()

def main():
	mode = 'filee'
	if mode == 'file':
		f = open('test.txt', 'r')
	get = lambda : [int(x) for x in (f.readline() if mode == 'file' else input()).split()]
	[t] = get()
	for z in range(t):
		g = list(input())
		if g.count('X') == 12:
			print('6 1x12 2x6 3x4 4x3 6x2 12x1')
			continue
		if g.count('X') == 0:
			print('0')
			continue
		if g.count('X') == 1:
			print('1 1x12')
			continue
		pos = []
		for i in range(12):
			if g[i] == 'X':
				pos.append(i + 1)
		solve(pos)
	if mode == 'file':
		f.close()
main()


t = int(input())
for i in range(t):
	ans = []
	s = input()
	e = [(1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)]
	for q in e:
		a = q[0]
		b = q[1]
		for i in range(b):
			w = True
			for j in range(i, 12, b):
				if s[j] != 'X':
					w = False
			if w:
				ans.append(q)
				break
	print(len(ans), *map(lambda x: str(x[0]) + 'x' + str(x[1]), ans))


def colExtract(matrix, i):
	return [row[i] for row in matrix]
NumOfGames = int(input())
(Games, gameSETS) = ([], ['1x12', '2x6', '3x4', '4x3', '6x2', '12x1'])
for i in range(NumOfGames):
	Games.append(str(input()))
for iteR_ in range(len(Games)):
	POTwins = []
	for game in gameSETS:
		(CURIndex, STRIndex) = (0, 0)
		(rows, cols, aGame) = (int(game.split('x')[0]), int(game.split('x')[1]), [])
		for k in range(rows):
			CURIndex += cols
			aGame.append([str(m) for m in Games[iteR_][STRIndex:CURIndex]])
			STRIndex += cols
		for k in range(cols):
			if all((x == 'X' for x in colExtract(aGame, k))):
				POTwins.append(game)
				break
	print(str(len(POTwins)) + ' ' + ' '.join(POTwins))


t = int(input())
for i in range(t):
	s = 1
	mas = [1, 12]
	a = str(input())
	o = 1
	if a[0] == 'O':
		x = 1
		while x < len(a):
			if a[x] == a[x - 1] and a[x] == 'O':
				o += 1
			x += 1
	if o == 12:
		print('0')
	else:
		x = 0
		y = 6
		while y < 12:
			if a[x] == a[y] and a[x] == 'X':
				s += 1
				mas.append(2)
				mas.append(6)
				break
			x += 1
			y += 1
		x = 0
		y = 4
		z = 8
		while z < 12:
			if a[x] == a[y] and a[y] == a[z] and (a[x] == 'X'):
				s += 1
				mas.append(3)
				mas.append(4)
				break
			x += 1
			y += 1
			z += 1
		x = 0
		y = 3
		z = 6
		i = 9
		while i < 12:
			if a[x] == a[y] and a[y] == a[z] and (a[z] == a[i]) and (a[x] == 'X'):
				s += 1
				mas.append(4)
				mas.append(3)
				break
			x += 1
			y += 1
			z += 1
			i += 1
		i = 0
		b = 2
		c = 4
		x = 6
		y = 8
		z = 10
		while z < 12:
			if a[i] == a[b] and a[b] == a[c] and (a[c] == a[x]) and (a[x] == a[y]) and (a[y] == a[z]) and (a[x] == 'X'):
				s += 1
				mas.append(6)
				mas.append(2)
				break
			i += 1
			b += 1
			c += 1
			x += 1
			y += 1
			z += 1
		if a[0] == 'X':
			x = 1
			sim = 1
			while x < len(a):
				if a[x] == a[x - 1]:
					sim += 1
				x += 1
			if sim == 12:
				mas.append(12)
				mas.append(1)
				s += 1
		print(s, end=' ')
		x = 0
		while x < len(mas):
			if x % 2 != 0:
				print(mas[x - 1], end='')
				print('x', end='')
				print(mas[x], end=' ')
			x += 1
		print()


constants = [1, 2, 3, 4, 6, 12]
constants.reverse()
k = int(input())
for i in range(k):
	value = input()
	result = []
	for elem in constants:
		matrix = [[value[i] for i in range(k, k + elem)] for k in range(0, 12, elem)]
		width = len(matrix[0])
		length = len(matrix)
		for i in range(width):
			matrix_found = True
			for j in range(length):
				if matrix[j][i] == 'O':
					matrix_found = False
					break
			if matrix_found:
				result.append(elem)
				break
	print(len(result), end=' ')
	for elem in result:
		print(str(12 // elem) + 'x' + str(elem), end=' ')
	print()


t = int(input())
tests = [[c for c in input()] for _ in range(t)]
multipliers = [12, 6, 4, 3, 2, 1]
compl = [12 // i for i in multipliers]
for test in tests:
	res = []
	for (k, m) in enumerate(multipliers):
		for j in range(0, m):
			disp = [e for (i, e) in enumerate(test[j:]) if i % m == 0 and e == 'X']
			if len(disp) == compl[k]:
				res.append('{}x{}'.format(compl[k], multipliers[k]))
				break
	print(str(len(res)), ' '.join(res))


R = lambda : map(int, input().split())
n = int(input())
for _ in range(n):
	s = input()
	good = []
	for g in (1, 2, 3, 4, 6, 12):
		for i in range(g):
			cnt = 0
			for j in range(12 // g):
				cnt += 1 if s[i + j * g] == 'X' else 0
			if cnt == 12 // g:
				good.append(g)
				break
	print(len(good), end=' ')
	for c in sorted(good, reverse=True):
		print(str(12 // c) + 'x' + str(c), end=' ')
	print()


def vamola(c, n=12):
	vitorias = set()
	for i in [1, 2, 3, 4, 6, 12]:
		flag = False
		k = 12 // i
		for d in range(k):
			colun = True
			for j in range(d, 12, k):
				colun = colun and c[j]
			flag = flag or colun
		if flag:
			vitorias.add(i)
	msg = ''
	for i in vitorias:
		msg += str(i) + 'x' + str(12 // i) + ' '
	return str(len(vitorias)) + ' ' + msg[:len(msg) - 1]
x = int(input())
for c in range(x):
	d = input()
	teste = []
	for j in range(12):
		if d[j] == 'O':
			teste.append(False)
		else:
			teste.append(True)
	print(vamola(teste))


from functools import reduce
print('\n'.join([(lambda x: '%i %s' % (len(x), ' '.join(x)))((lambda h: ['%ix%i' % (12 // i, i) for i in (12, 6, 4, 3, 2, 1) if reduce(lambda x, y: x & y, [int(h.replace('O', '0').replace('X', '1')[i * j:i * j + i], 2) for j in range(12 // i)], -1)])(input())) for i in range(int(input()))]))


(Numbers, N) = ([2, 3, 4, 6], int(input()))
for i in range(N):
	X = input()
	Answer = []
	if 'X' in X:
		Answer.append('1x12')
	for j in Numbers:
		for k in range(12 // j):
			Temp = ''
			for l in range(j):
				Temp += X[12 // j * l + k]
			if 'O' not in Temp:
				Answer.append(str(j) + 'x' + str(12 // j))
				break
	if 'O' not in X:
		Answer.append('12x1')
	print(len(Answer), end=' ')
	print(*Answer)


n = eval(input())
i = 0
c = 0
e = 0
E = ''
while i < n:
	b = input()
	y = 'n'
	while c < 12 and y == 'n':
		if b[c] == 'X':
			y = 'f'
		c += 1
	if y == 'f':
		E += ' 1x12 '
		e += 1
	if b[0] == b[6] == 'X' or b[1] == b[7] == 'X' or b[2] == b[8] == 'X' or (b[3] == b[9] == 'X') or (b[4] == b[10] == 'X') or (b[5] == b[11] == 'X'):
		E += ' 2x6 '
		e += 1
	if b[0] == b[4] == b[8] == 'X' or b[1] == b[5] == b[9] == 'X' or b[2] == b[6] == b[10] == 'X' or (b[3] == b[7] == b[11] == 'X'):
		E += ' 3x4 '
		e += 1
	if b[0] == b[3] == b[6] == b[9] == 'X' or b[1] == b[4] == b[7] == b[10] == 'X' or b[2] == b[5] == b[8] == b[11] == 'X':
		E += ' 4x3 '
		e += 1
	if b[0] == b[2] == b[4] == b[6] == b[8] == b[10] == 'X' or b[1] == b[3] == b[5] == b[7] == b[9] == b[11] == 'X':
		E += ' 6x2 '
		e += 1
	if b[0] == b[1] and b[0] == b[2] and (b[0] == b[3]) and (b[0] == b[4]) and (b[0] == b[5]) and (b[0] == b[6]) and (b[0] == b[7]) and (b[0] == b[8]) and (b[0] == b[9]) and (b[0] == b[10]) and (b[0] == b[11]) and (b[0] == 'X'):
		E += ' 12x1 '
		e += 1
	print(e, E)
	E = ''
	e = 0
	c = 0
	i += 1


import math

def main_function():
	t = int(input())
	cards = [input() for i in range(t)]
	a = [1, 2, 3, 4, 6, 12]
	b = [12 // a[i] for i in range(len(a))]
	for card in cards:
		bools = [False for i in range(len(a))]
		index_collector = []
		for j in range(len(card)):
			if card[j] == 'X':
				index_collector.append(j + 1)
		for ind in range(len(a)):
			a_i = a[ind]
			hash = [0 for f in range(b[ind])]
			for i in index_collector:
				hash[i % b[ind]] += 1
			if max(hash) >= a[ind]:
				bools[ind] = True
		counter = 0
		for i in bools:
			if i:
				counter += 1
		output = [str(counter)] + [str(a[i]) + 'x' + str(b[i]) for i in range(len(a)) if bools[i]]
		print(' '.join(output))
main_function()


from sys import stdin, stdout
n = int(stdin.readline())
a = [1, 2, 3, 4, 6, 12]
for i in range(n):
	s = stdin.readline()
	ans = list()
	for x in a:
		p = 12 // x
		for start in range(1, p + 1):
			flag = True
			for col in range(0, x):
				if s[start - 1 + col * p] != 'X':
					flag = False
			if flag:
				ans.append(' ' + str(x) + 'x' + str(p))
				break
	stdout.write(str(len(ans)))
	for st in ans:
		stdout.write(st)
	stdout.write('\n')


t = int(input())
for i in range(t):
	word = input()
	a = []
	cek = []
	for i in [1, 2, 3, 4, 6, 12]:
		div = int(12 / i)
		for u in range(div):
			boo = True
			j = u
			while j <= 11:
				if word[j] == 'X':
					j += div
				else:
					boo = False
					break
			if boo:
				a.append(i)
				break
	print(len(a), end=' ')
	for i in a:
		print(i, 'x', int(12 / i), end=' ', sep='')
	print()


a = int(input())
l = []
for i in range(a):
	c = input()
	l.append(c)
for i in range(a):
	p = l[i]
	s = []
	for i in range(12):
		if p[i] == 'X':
			s.append('1x12')
			break
	for i in range(6):
		if p[i] == 'X' and p[i + 6] == 'X':
			s.append('2x6')
			break
	for i in range(4):
		if p[i] == p[i + 4] == p[i + 8] == 'X':
			s.append('3x4')
			break
	for i in range(3):
		if p[i] == p[i + 3] == p[i + 6] == p[i + 9] == 'X':
			s.append('4x3')
			break
	for i in range(2):
		m = 1
		for j in range(i, 12, 2):
			if p[j] != 'X':
				m = 0
				break
		if m == 1:
			s.append('6x2')
			break
	t = 0
	for i in range(12):
		if p[i] != 'X':
			t = 1
			break
	if t == 0:
		s.append('12x1')
	if len(s) == 0:
		print(0)
	else:
		o = len(s)
		r = str(o)
		for k in range(len(s)):
			r = r + ' ' + s[k]
		print(r)


for _ in range(int(input())):
	s = input()
	A = [str(a) + 'x' + str(12 // a) for a in (1, 2, 3, 4, 6, 12) if any((s[i::12 // a] == 'X' * a for i in range(12 // a)))]
	print(len(A), *A)


for i in range(int(input())):
	(s, arr) = (input(), ['1x12'])
	if s.find('X') == -1:
		print(0)
		continue
	for j in range(6, 0, -1):
		if j == 5:
			continue
		for k in range(j):
			if s[k::j].find('O') == -1:
				arr.append('{}x{}'.format(12 // j, j))
				break
	print(len(arr), *arr)


def isMatch(n, s):
	x = 12 // n
	res = []
	for i in range(0, len(s), x):
		res.append(s[i:i + x])
	for col in range(x):
		for row in range(len(res)):
			if res[row][col] != 'X':
				break
			elif res[row][col] == 'X' and row == len(res) - 1:
				return True
	return False

def solve(s):
	res = []
	if 'X' in s:
		res.append('1x12')
	for i in [2, 3, 4, 6]:
		if isMatch(i, s):
			res.append(f'{i}x{12 // i}')
	if s == 12 * 'X':
		res.append('12x1')
	print(len(res), sep=' ', end=' ')
	print(*res)

def main():
	n = int(input())
	arr = []
	for _ in range(n):
		i = input()
		arr.append(i)
	for i in arr:
		solve(i)
main()


t = int(input())
for _ in range(t):
	s = input()
	l = []
	m1 = [str(i) for i in s]
	m2 = [s[0] + s[6], s[1] + s[7], s[2] + s[8], s[3] + s[9], s[4] + s[10], s[5] + s[11]]
	m4 = [s[0] + s[3] + s[6] + s[9], s[1] + s[4] + s[7] + s[10], s[2] + s[5] + s[8] + s[11]]
	m3 = [s[0] + s[4] + s[8], s[1] + s[5] + s[9], s[2] + s[6] + s[10], s[3] + s[7] + s[11]]
	m5 = [s[0] + s[2] + s[4] + s[6] + s[8] + s[10], s[1] + s[3] + s[5] + s[7] + s[9] + s[11]]
	m6 = [s[0] + s[1] + s[2] + s[3] + s[4] + s[5] + s[6] + s[7] + s[8] + s[9] + s[10] + s[11]]
	if 'X' * 1 in m1:
		l.append('1x12')
	if 'X' * 2 in m2:
		l.append('2x6')
	if 'X' * 3 in m3:
		l.append('3x4')
	if 'X' * 4 in m4:
		l.append('4x3')
	if 'X' * 6 in m5:
		l.append('6x2')
	if 'X' * 12 in m6:
		l.append('12x1')
	print(len(l), end=' ')
	print(*l)


def do(string):
	num = 0
	ok = []
	for i in [12, 6, 4, 3, 2, 1]:
		for j in range(0, i):
			if string[j::i] == 'X' * int(12 / i):
				ok.append(str(int(12 / i)) + 'x' + str(i))
				num += 1
				break
	ok = [str(num)] + ok
	print(' '.join(ok))
for i in range(int(input())):
	do(input())


import sys
import math
t = int(sys.stdin.readline())
for i in range(t):
	st = sys.stdin.readline()
	p1 = 1
	p2 = [1] * 2
	p3 = [1] * 3
	p4 = [1] * 4
	p6 = [1] * 6
	p12 = 0
	for j in range(1, 13):
		v = 0
		if st[j - 1] == 'X':
			v = 1
		p1 &= v
		p2[j % 2] &= v
		p3[j % 3] &= v
		p4[j % 4] &= v
		p6[j % 6] &= v
		p12 += v
	res = []
	if p12 > 0:
		res.append('1x12')
	if sum(p6) > 0:
		res.append('2x6')
	if sum(p4) > 0:
		res.append('3x4')
	if sum(p3) > 0:
		res.append('4x3')
	if sum(p2) > 0:
		res.append('6x2')
	if p1 > 0:
		res.append('12x1')
	print(str(len(res)) + ' ' + ' '.join(res))


t = int(input())
for i in range(0, t):
	str = input()
	answer = []
	p = [1, 2, 3, 4, 6, 12]
	for j in range(0, len(p)):
		(d1, d2) = (p[j], 12 // p[j])
		cnt = [0 for h in range(0, d2)]
		for i2 in range(0, 12):
			tt = i2 % d2
			cnt[tt] += str[i2] == 'X'
		ans_cand = False
		for i2 in range(0, d2):
			if cnt[i2] == d1:
				ans_cand = True
		if ans_cand:
			answer.append('%dx%d' % (d1, d2))
	print(len(answer), end=' ')
	for j in range(0, len(answer)):
		print(answer[j], end=' ')
	print()


n = int(input())
results = []
for i in range(n):
	res = []
	line = list(input())
	for k in range(1, 13):
		if 12 % k == 0:
			a = 12 // k
			b = k
			boleh = False
			for l in range(b):
				count = 0
				for j in range(l, 12, b):
					if line[j] == 'X':
						count += 1
				if count == a:
					boleh = True
			if boleh:
				res.append(str(a) + 'x' + str(b))
	results.append(res)
for result in results:
	print(str(len(result)), end=' ')
	print(*result[::-1], sep=' ')


for _ in range(int(input())):
	s = input()
	l = []
	for i in range(1, 13):
		if 12 % i == 0:
			for j in range(0, 12):
				if s[j::12 // i] == 'X' * i:
					l.append(str(i) + 'x' + str(12 // i))
					break
	print(len(l), ' '.join(l))


n = int(input())
for i in range(n):
	x = input()
	res = []
	for j in [1, 2, 3, 4, 6, 12]:
		valid = False
		for k in range(12 // j):
			s = set(x[k::12 // j])
			if len(s) == 1 and 'X' in s:
				valid = True
				break
		if valid:
			res.append('{}x{}'.format(j, 12 // j))
	print(len(res), ' '.join(res))


import math
import os
import random
import re
import sys
import functools
import datetime as dt
from operator import itemgetter, attrgetter
from collections import Counter
N = lambda : int(input())
t = N()
(a, r) = ([1, 2, 3, 4, 6, 12], list())
while t > 0:
	s = input()
	for i in a:
		for j in range(12 // i):
			if s[j::12 // i].count('X') == i:
				r.append('%sx%s' % (i, 12 // i))
				break
	print(len(r), *r)
	r.clear()
	t -= 1


t = int(input())
for tc in range(t):
	s = input().rstrip()
	res = []
	if 'X' in s:
		res.append('1x12')
	for n in [1, 2, 3, 4, 6]:
		for i in range(n):
			if s[i::n].count('O') == 0:
				res.append(str(12 // n) + 'x' + str(n))
				break
	res = list(set(res))
	res.sort(key=lambda x: int(x[:x.index('x')]))
	print(len(res), ' '.join(res))


for _ in range(int(input())):
	cards = input()
	count = 0
	output = ''
	if 'X' in cards:
		count += 1
		output += ' 1x12'
	for (q, p) in zip(cards[:6], cards[6:]):
		if q == p == 'X':
			count += 1
			output += ' 2x6'
			break
	for (q, p, r) in zip(cards[:4], cards[4:8], cards[8:]):
		if q == p == r == 'X':
			count += 1
			output += ' 3x4'
			break
	for (q, p, r, s) in zip(cards[:3], cards[3:6], cards[6:9], cards[9:]):
		if q == p == r == s == 'X':
			count += 1
			output += ' 4x3'
			break
	for (q, p, r, s, t, u) in zip(cards[:2], cards[2:4], cards[4:6], cards[6:8], cards[8:10], cards[10:]):
		if q == p == r == s == t == u == 'X':
			count += 1
			output += ' 6x2'
			break
	if 'O' not in cards:
		count += 1
		output += ' 12x1'
	print(str(count) + output)


for _ in range(int(input())):
	s = input()
	n = len(s)
	ans = []
	d = [1, 2, 3, 4, 6, 12]
	for item in d:
		z = 12 // item
		for i in range(z):
			if s[i::z] == 'X' * item:
				ans.append((item, z))
				break
	print(len(ans), end=' ')
	ans.sort()
	for item in ans:
		print(f'{item[0]}x{item[1]}', end=' ')
	print()


a = int(input())
while a:
	l = []
	b = input()
	if b.count('X') > 0:
		l.append('1x12')
	if b[:6].count('X') > 0:
		p = [i for i in range(6) if b[i] == 'X']
		for i in p:
			if b[i:12:6] == 'XX':
				l.append('2x6')
				break
	if b[:4].count('X') > 0:
		p = [i for i in range(4) if b[i] == 'X']
		for i in p:
			if b[i:12:4] == 'XXX':
				l.append('3x4')
				break
	if b[:3].count('X') > 0:
		p = [i for i in range(3) if b[i] == 'X']
		for i in p:
			if b[i:12:3] == 'XXXX':
				l.append('4x3')
				break
	if b[:2].count('X') > 0:
		p = [i for i in range(2) if b[i] == 'X']
		for i in p:
			if b[i:12:2] == 'XXXXXX':
				l.append('6x2')
				break
	if b.count('X') == 12:
		l.append('12x1')
	print(len(l), end=' ')
	if len(l) > 0:
		for i in l:
			print(i, end=' ')
	print()
	a -= 1


def mat_maker(b, row):
	mat = []
	col = []
	for (idx, val) in enumerate(row):
		col.append(val)
		if (idx + 1) % b == 0:
			mat.append(col)
			col = []
	return col_checker(mat, b)

def col_checker(mat, b):
	col = []
	ans = False
	a = 12 // b
	for i in range(b):
		col = []
		for j in range(a):
			col.append(mat[j][i])
		if set(col) == {'X'}:
			ans = True
			break
	return ans
n = int(input())
matrix = []
for _ in range(n):
	tmp = list(input())
	matrix.append(tmp)
bs = [12, 6, 4, 3, 2, 1]
for row in matrix:
	ans = []
	for b in bs:
		ok = mat_maker(b, row)
		if ok:
			ans.append(f'{12 // b}x{b}')
	ans.insert(0, len(ans))
	print(*ans)
	ans = []


class MyApp:

	def build(self, s):
		p = 0
		res = [12, -1, -1, -1, -1, 1]
		for i in range(12):
			if s[i] == 'O':
				res[0] -= 1
				res[5] -= 1
		if res[0] > 0:
			p += 1
		if res[5] > 0:
			p += 1
		indp = -1
		REP = [6, 4, 3, 2]
		ind = 0
		for i in range(4):
			for _ in range(REP[ind]):
				if ''.join(s[_::REP[ind]]) == 'X' * REP[indp]:
					res[i + 1] = 1
					p += 1
					break
			ind += 1
			indp -= 1
		ans = ['1x12', '2x6', '3x4', '4x3', '6x2', '12x1']
		print(p, end=' ')
		for i in range(6):
			if res[i] > 0:
				print(ans[i], end=' ')
		print()
root = MyApp()
for i in range(int(input())):
	root.build(input())


def check(a, b, s, ans):
	for j in range(b):
		if [s[k] for k in range(12) if k % b == j].count('X') == a:
			ans.append('%dx%d' % (a, b))
			return ans
	return ans
t = int(input())
for i in range(t):
	ans = []
	s = input()
	ans = check(1, 12, s, ans)
	ans = check(2, 6, s, ans)
	ans = check(3, 4, s, ans)
	ans = check(4, 3, s, ans)
	ans = check(6, 2, s, ans)
	ans = check(12, 1, s, ans)
	if ans:
		print(len(ans), ' '.join(ans))
	else:
		print(0)


t = int(input())
for i in range(t):
	s = input()
	ans = ''
	count = 0
	for j in range(1, 13):
		flag = False
		if 12 % j == 0:
			for p in range(12 // j):
				q = p
				while q < 12 and s[q] == 'X':
					q += 12 // j
				if q >= 12:
					flag = True
		if flag:
			ans += str(j) + 'x' + str(12 // j) + ' '
			count += 1
	print(count, ans[:-1])


n = int(input())
a = [1, 2, 3, 4, 6, 12]
for i in range(0, n):
	s = str(input())
	ans = [False for x in range(0, 6)]
	nans = 0
	for i in range(0, 6):
		for j in range(0, 12 // a[i]):
			good = True
			for k in range(0, a[i]):
				if s[k * 12 // a[i] + j] is 'O':
					good = False
					break
			if good:
				nans = nans + 1
				ans[i] = True
				break
	print(nans, end=' ')
	for i in range(0, 6):
		if ans[i]:
			print(str(a[i]) + 'x' + str(12 // a[i]), end=' ')
	print()


n = int(input())
for i in range(n):
	cnt = 0
	answ = ['1x12', '2x6', '3x4', '4x3', '6x2', '12x1']
	answb = [False, False, False, False, False, False]
	instr = input()
	if 'X' in instr:
		cnt += 1
		answb[0] = True
	for j in range(6):
		if instr[j] == instr[6 + j] == 'X':
			cnt += 1
			answb[1] = True
			break
	for j in range(4):
		if instr[j] == instr[4 + j] == instr[8 + j] == 'X':
			cnt += 1
			answb[2] = True
			break
	for j in range(3):
		if instr[j] == instr[3 + j] == instr[6 + j] == instr[9 + j] == 'X':
			cnt += 1
			answb[3] = True
			break
	for j in range(2):
		if instr[j] == instr[2 + j] == instr[4 + j] == instr[6 + j] == instr[8 + j] == instr[10 + j] == 'X':
			cnt += 1
			answb[4] = True
			break
	if not 'O' in instr:
		cnt += 1
		answb[5] = True
	print(cnt, end=' ')
	for i in range(6):
		if answb[i]:
			print(answ[i], end=' ')
	print()


def ok(s, a, b):
	mat = []
	for i in range(0, len(s), b):
		mat.append(s[i:i + b])
	for j in range(b):
		c = 0
		for i in range(a):
			if mat[i][j] == 'O':
				c += 1
		if not c:
			return True
	return False
t = int(input())
for _ in range(t):
	s = input()
	x = s.count('X')
	pos = [[1, 12], [2, 6], [3, 4], [4, 3], [6, 2], [12, 1]]
	ans = 0
	for (i, j) in pos:
		if ok(s, i, j):
			ans += 1
	print(ans, end=' ')
	for (i, j) in pos:
		if ok(s, i, j):
			print(f'{i}x{j}', end=' ')
	print()