#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long pw(long long a, long long b) {
  long long r = 1;
  while (b > 0) {
    if (b & 1) {
      r = (r * a) % MOD;
    }
    b = b >> 1;
    a = (a * a) % MOD;
  }
  return (r) % MOD;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int a = 1, b;
    vector<int> v;
    string s;
    cin >> s;
    while (a <= 12) {
      if ((12 % a) == 0) {
        b = 12 / a;
        int pos = 0;
        for (int pr = 0; pr < b; pr++) {
          pos = pr;
          int c = 0;
          for (int i = 0; i < a; i++) {
            if (s[pos] == 'X') {
              c++;
            }
            for (int j = 0; j < b; j++) {
              pos++;
            }
          }
          if (c == a) {
            v.push_back(a);
            break;
          }
        }
      }
      a++;
    }
    printf("%d", (int)v.size());
    for (int i = 0; i < v.size(); i++) {
      cout << " " << v[i] << "x" << 12 / v[i];
    }
    printf("\n");
  }
  return 0;
}
