#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, count = 0, a1, a2, a3, a4, a5, a6;
  string s;
  cin >> n;
  while (n--) {
    a1 = a2 = a3 = a4 = a5 = a6 = 0;
    count = 0;
    cin >> s;
    for (long long int i = 0; i < 12; ++i) {
      if (s[i] == 'X') {
        ++count;
        a1 = 1;
        break;
      } else
        continue;
    }
    for (long long int i = 0; i < 6; ++i) {
      if (s[i] == 'X' && s[i + 6] == 'X') {
        ++count;
        a2 = 1;
        break;
      } else
        continue;
    }
    for (long long int i = 0; i < 4; ++i) {
      if (s[i] == 'X' && s[i + 4] == 'X' && s[i + 8] == 'X') {
        ++count;
        a3 = 1;
        break;
      }
    }
    for (long long int i = 0; i < 3; ++i) {
      if (s[i] == 'X' && s[i + 3] == 'X' && s[i + 6] == 'X' &&
          s[i + 9] == 'X') {
        ++count;
        a4 = 1;
        break;
      }
    }
    for (long long int i = 0; i < 2; ++i) {
      if (s[i] == 'X' && s[i + 2] == 'X' && s[i + 4] == 'X' &&
          s[i + 6] == 'X' && s[i + 8] == 'X' && s[i + 10] == 'X') {
        ++count;
        a5 = 1;
        break;
      }
    }
    for (long long int i = 0; i < 12; ++i) {
      if (s[i] == 'X') ++a6;
    }
    if (a6 == 12) ++count;
    printf("%I64d ", count);
    if (a1 == 1) printf("1x12 ");
    if (a2 == 1) printf("2x6 ");
    if (a3 == 1) printf("3x4 ");
    if (a4 == 1) printf("4x3 ");
    if (a5 == 1) printf("6x2 ");
    if (a6 == 12) printf("12x1 ");
    printf("\n");
  }
  return 0;
}
