#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
set<int> c = {1, 2, 3, 4, 6, 12};
int main() {
  ios_base::sync_with_stdio(0);
  int n, i, y, j;
  string s;
  cin >> n;
  while (n--) {
    cin >> s;
    bool flag;
    ans.clear();
    for (int x : c) {
      y = 12 / x;
      for (i = 0; i < y; i++) {
        flag = true;
        for (j = 0; j < x; j++) {
          if (s[j * y + i] == 'O') {
            flag = false;
            break;
          }
        }
        if (flag) {
          ans.push_back(x);
          break;
        }
      }
    }
    cout << ans.size() << " ";
    for (int x : ans) {
      cout << x << "x" << 12 / x << " ";
    }
    cout << "\n";
  }
  return 0;
}
