#include <bits/stdc++.h>
int main(void) {
  int k, i, j, a, count, flag;
  char cards[13], valid[13];
  scanf("%d\n", &k);
  while (k--) {
    gets(cards);
    count = 0;
    for (a = 1; a <= 12; a++) {
      valid[a] = 0;
      if (12 % a) continue;
      for (i = 0; i < 12 / a; i++) {
        flag = 1;
        for (j = 0; j < a; j++)
          if (cards[j * (12 / a) + i] != 'X') {
            flag = 0;
            break;
          }
        if (flag) {
          count++;
          valid[a] = 1;
          break;
        }
      }
    }
    printf("%d", count);
    for (i = 1; i <= 12; i++)
      if (valid[i]) printf(" %dx%d", i, 12 / i);
    putchar('\n');
  }
  return 0;
}
