#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, l, c;
  bool f;
  cin >> i;
  string s;
  vector<int> v;
  while (i--) {
    cin >> s;
    k = 0;
    c = 0;
    v.clear();
    for (j = 1; j <= 12; j++) {
      if (12 % j == 0) {
        for (k = 0; k < (12 / j); k++) {
          f = true;
          for (l = 0; l < j; l++) {
            if (s[k + l * (12 / j)] == 'O') {
              f = false;
            }
          }
          if (f == true) {
            c++;
            v.push_back(j);
            break;
          }
        }
      }
    }
    cout << c << ' ';
    for (j = 0; j < v.size(); j++) {
      cout << v[j] << 'x' << 12 / v[j] << ' ';
    }
    cout << endl;
  }
}
