#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, c;
  string s;
  vector<string> v;
  cin >> t;
  while (t--) {
    cin >> s;
    for (int i = 1; i <= 12; i++) {
      if (12 % i == 0) {
        for (int j = 0; j < i; j++) {
          c = 0;
          for (int k = 0; k < 12 / i; k++)
            if (s[j + k * i] == 'X') c++;
          if (c == 12 / i) {
            v.push_back(to_string(12 / i) + "x" + to_string(i));
            break;
          }
        }
      }
    }
    cout << v.size() << " ";
    for (int i = v.size() - 1; i >= 0; i--) cout << v[i] << " ";
    cout << endl;
    v.clear();
  }
  return 0;
}
