#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int c = 0;
    vector<int> v;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == 'X') c++;
    }
    if (c >= 1) {
      v.push_back(1);
    }
    if (c == 12) {
      v.push_back(12);
    }
    for (int i = 0; i < 6; i++) {
      if (s[i] == s[i + 6] && s[i] == 'X') {
        v.push_back(2);
        break;
      }
    }
    for (int i = 0; i < 4; i++) {
      if (s[i] == s[i + 4] && s[i + 4] == s[i + 8] && s[i] == 'X') {
        v.push_back(3);
        break;
      }
    }
    for (int i = 0; i < 2; i++) {
      if (s[i] == s[i + 2] && s[i + 2] == s[i + 4] && s[i + 4] == s[i + 6] &&
          s[i + 6] == s[i + 8] && s[i + 8] == s[i + 10] && s[i] == 'X') {
        v.push_back(6);
        break;
      }
    }
    for (int i = 0; i < 3; i++) {
      if (s[i] == s[i + 3] && s[i + 3] == s[i + 6] && s[i + 6] == s[i + 9] &&
          s[i] == 'X') {
        v.push_back(4);
        break;
      }
    }
    cout << v.size() << " ";
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
      cout << v[i] << "x" << 12 / v[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
