#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long MAX_N = 5010;
const long long INF = 1e8;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  int t;
  cin >> t;
  vector<vector<pair<int, int>>> ps;
  for (int x = 0; x < t; ++x) {
    string s;
    cin >> s;
    vector<pair<int, int>> m;
    for (int i = 12; i >= 1; --i) {
      if (12 % i == 0) {
        string cols[i];
        for (int j = 0; j < i; ++j) cols[j] = "";
        for (int j = 0; j < 12; j += i) {
          string f = s.substr(j, i);
          for (int k = 0; k < f.length(); ++k) cols[k] += f[k];
        }
        for (int j = 0; j < i; ++j)
          if (cols[j].find('O') == cols[j].npos) {
            m.push_back({12 / i, i});
            break;
          }
      }
    }
    ps.push_back(m);
  }
  for (auto x : ps) {
    cout << x.size() << " ";
    for (auto j : x) {
      cout << j.first << "x" << j.second << " ";
    }
    cout << endl;
  }
  return 0;
}
