#include <bits/stdc++.h>
using namespace std;
const int N = 20;
int n;
char s[N];
char str[N][N];
int flag;
int ans;
int tt(int a, int b) {
  int i, j;
  for (i = 0; i < a; i++)
    for (j = 0; j < b; j++) {
      str[i][j] = s[i * b + j];
    }
  for (i = 0; i < b; i++) {
    for (j = 0; j < a; j++) {
      if (str[j][i] != 'X') break;
    }
    if (j == a) return 1;
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  while (n--) {
    ans = 0;
    scanf("%s", &s);
    if (tt(1, 12)) ans++;
    if (tt(2, 6)) ans++;
    if (tt(3, 4)) ans++;
    if (tt(4, 3)) ans++;
    if (tt(6, 2)) ans++;
    if (tt(12, 1)) ans++;
    printf("%d", ans);
    if (tt(1, 12)) printf(" 1x12");
    if (tt(2, 6)) printf(" 2x6");
    if (tt(3, 4)) printf(" 3x4");
    if (tt(4, 3)) printf(" 4x3");
    if (tt(6, 2)) printf(" 6x2");
    if (tt(12, 1)) printf(" 12x1");
    printf("\n");
  }
  return 0;
}
