#include <bits/stdc++.h>
using namespace std;
bool check(int a, int b, string s) {
  vector<string> v;
  for (int i = 0; i < (int)(a); ++i) {
    v.push_back(s.substr(i * b, b));
  }
  for (int i = 0; i < (int)(b); ++i) {
    int cnt = 0;
    for (int j = 0; j < (int)(a); ++j)
      if (v[j][i] == 'X') ++cnt;
    if (cnt == a) return true;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) {
    vector<string> ans;
    string s;
    cin >> s;
    for (int a = 1; a < 13; ++a) {
      for (int b = 1; b < 13; ++b) {
        if (a * b != 12) continue;
        if (check(a, b, s)) {
          stringstream ss;
          ss << a << "x" << b;
          ans.push_back(ss.str());
        }
      }
    }
    cout << ans.size();
    for (int i = 0; i < (int)(ans.size()); ++i) cout << " " << ans[i];
    cout << endl;
  }
  return 0;
}
