#include <bits/stdc++.h>
using namespace std;
int n, f;
string s;
vector<int> ans;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    f = 0;
    cin >> s;
    ans.clear();
    for (int j = 1; j <= 12; j++) {
      f = 0;
      if (12 % j > 0) continue;
      for (int q = 1; q <= j; q++) {
        f = 0;
        for (int u = q - 1; u < 12; u += j) {
          if (s[u] == 'O') f = 1;
        }
        if (!f) {
          ans.push_back(j);
          break;
        }
      }
    }
    cout << ans.size() << " ";
    for (int j = ans.size() - 1; j >= 0; j--)
      cout << 12 / ans[j] << "x" << ans[j] << " ";
    cout << endl;
  }
}
