#include <bits/stdc++.h>
using namespace std;
void ans(string str) {
  vector<pair<int, int> > r;
  for (int a = 1; a <= 12; ++a) {
    if (12 % a == 0) {
      int b = 12 / a;
      vector<string> f(a, string(b, ' '));
      int k = 0;
      for (int i = 0; i < a; ++i) {
        for (int j = 0; j < b; ++j) {
          f[i][j] = str[k++];
        }
      }
      bool win = false;
      for (int j = 0; j < b; ++j) {
        bool ok = true;
        for (int i = 0; i < a; ++i) {
          if (f[i][j] != 'X') ok = false;
        }
        if (ok) win = true;
      }
      if (win) r.push_back(make_pair(a, b));
    }
  }
  cout << r.size();
  for (int i = 0; i < r.size(); ++i)
    cout << " " << r[i].first << "x" << r[i].second;
  cout << "\n";
}
int main() {
  int t;
  cin >> t;
  string s;
  for (int i = 0; i < t; ++i) {
    cin >> s;
    ans(s);
  }
}
