#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    vector<pair<int, int>> res;
    string s;
    cin >> s;
    for (int i = 1; i <= 12; i++) {
      bool ok = 1;
      if (12 % i == 0) {
        for (int j = 0; j < 12 / i; j++) {
          ok = 1;
          for (int k = 0; k < i; k++) {
            ok &= s[k * 12 / i + j] == 'X';
          }
          if (ok) {
            res.push_back({i, 12 / i});
            break;
          }
        }
      }
    }
    cout << res.size() << ' ';
    for (auto i : res) cout << i.first << 'x' << i.second << ' ';
    cout << '\n';
  }
  return 0;
}
