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