#include <bits/stdc++.h>
using namespace std;
unsigned long long mod = 1000000007;
int main() {
  int tests;
  cin >> tests;
  string inp;
  while (tests--) {
    std::vector<pair<int, int> > ret;
    inp.clear();
    cin >> inp;
    if (inp.find('X') != -1) ret.push_back(make_pair(1, 12));
    for (int pos = 0; pos < 6; pos++)
      if (inp[pos] == 'X' and inp[pos + 6] == 'X') {
        ret.push_back(make_pair(2, 6));
        break;
      }
    for (int pos = 0; pos < 4; pos++)
      if (inp[pos] == 'X' and inp[pos + 4] == 'X' and inp[pos + 8] == 'X') {
        ret.push_back(make_pair(3, 4));
        break;
      }
    for (int pos = 0; pos < 3; pos++)
      if (inp[pos] == 'X' and inp[pos + 3] == 'X' and inp[pos + 6] == 'X' and
          inp[pos + 9] == 'X') {
        ret.push_back(make_pair(4, 3));
        break;
      }
    for (int pos = 0; pos < 2; pos++)
      if (inp[pos] == 'X' and inp[pos + 2] == 'X' and inp[pos + 4] == 'X' and
          inp[pos + 6] == 'X' and inp[pos + 8] == 'X' and
          inp[pos + 10] == 'X') {
        ret.push_back(make_pair(6, 2));
        break;
      }
    if (inp.find('O') == -1) ret.push_back(make_pair(12, 1));
    cout << int((ret).size());
    (int((ret).size()) == 0) ? cout << "\n" : cout << " ";
    for (int pos = 0; pos < int((ret).size()); pos++) {
      cout << ret[pos].first << "x" << ret[pos].second;
      (pos == int((ret).size()) - 1) ? cout << "\n" : cout << " ";
    }
  }
  return 0;
}
