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