#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  for (int t = 0; t < T; t++) {
    char s[20];
    cin >> s;
    vector<pair<int, int> > v;
    for (int i = 1; i <= 12; i++)
      if (12 % i == 0) {
        bool win = false;
        for (int j = 0; j < 12 / i; j++) {
          bool f = true;
          for (int k = 0; k < i; k++)
            if (s[k * (12 / i) + j] == 'O') f = false;
          if (f) win = true;
        }
        if (win) v.push_back(make_pair(i, 12 / i));
      }
    cout << v.size();
    for (int i = 0; i < v.size(); i++)
      cout << " " << v[i].first << "x" << v[i].second;
    cout << "\n";
  }
  return 0;
}
