#include <bits/stdc++.h>
long long a[100005] = {};
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    vector<int> v;
    int n = s.length();
    int count = 0;
    for (int i = 1; i <= 12; i++) {
      if (12 % i == 0) {
        for (int k = 0; k < n; k++) {
          int temp = 0;
          for (int j = 0; k + j * i < n; j++) {
            if (s[k + j * i] == 'X') temp++;
          }
          if (temp == 12 / i) {
            v.push_back(12 / i);
            count++;
            k = n;
          }
        }
      }
    }
    sort(v.begin(), v.end());
    cout << count << " ";
    for (int i = 0; i < count; i++) {
      cout << v[i] << "x" << 12 / v[i] << " ";
    }
    cout << "\n";
  }
}
