#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  vector<pair<int, int> > v;
  while (t--) {
    string s;
    cin >> s;
    int n = s.size();
    for (int k = 1; k <= 12; k++)
      if (12 % k == 0) {
        for (int i = 0; i < k; i++) {
          int cur = 0;
          for (int j = i; j < n; j += k) {
            if (s[j] == 'X') cur++;
          }
          if (cur == n / k) {
            v.push_back(make_pair(k, n / k));
            break;
          }
        }
      }
    sort(v.rbegin(), v.rend());
    cout << v.size() << " ";
    for (int i = 0; i < v.size(); i++)
      cout << v[i].second << "x" << v[i].first << " ";
    cout << endl;
    v.erase(v.begin(), v.end());
  }
}
