#include <bits/stdc++.h>
using namespace std;
int kkaass = 1;
int main() {
  int t;
  cin >> t;
  string a;
  while (t--) {
    cin >> a;
    vector<pair<int, int> > ans;
    for (int i = 1; i <= 12; i++) {
      if (12 % i == 0) {
        int x = i, y = 12 / i;
        char bd[12][12];
        int ind = 0;
        for (int j = 0; j < x; j++) {
          for (int k = 0; k < y; k++) bd[j][k] = a[ind++];
        }
        for (int j = 0; j < y; j++) {
          int k;
          for (k = 0; k < x; k++) {
            if (bd[k][j] == 'O') break;
          }
          if (k == x) {
            ans.push_back(make_pair(x, y));
            break;
          }
        }
      }
    }
    cout << (int)ans.size();
    for (int i = 0; i < (int)ans.size(); i++)
      cout << " " << ans[i].first << "x" << ans[i].second;
    cout << endl;
  }
  return 0;
}
