#include <bits/stdc++.h>
int main() {
  int i, j, t, n, k, f;
  char s[15];
  int x[6] = {1, 2, 3, 4, 6, 12};
  int a[20], b[20];
  scanf("%d", &t);
  while (t--) {
    scanf("%s", s);
    memset(b, 0, sizeof(b));
    k = n = 0;
    for (i = 0; i < 6; i++) {
      memset(a, 0, sizeof(a));
      for (j = 0; j < 12; j++) {
        if (s[j] == 'X') {
          a[j % (12 / x[i])]++;
        }
      }
      f = 0;
      for (j = 0; j < 12; j++) {
        if (a[j] == x[i]) {
          f = 1;
        }
      }
      if (f == 1) {
        n++;
        b[k++] = x[i];
      }
    }
    printf("%d", n);
    if (n != 0) printf(" ");
    for (i = 0; i < n; i++) {
      printf("%dx%d", b[i], 12 / b[i]);
      if (i != n - 1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}
