#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
using ll = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
void solve() {
  string s;
  cin >> s;
  vi ans;
  int cnt = 0;
  for (int a = 1; a <= 12; a++) {
    if (12 % a != 0) continue;
    int b = 12 / a;
    vector<bool> go(b, false);
    int i = 0;
    for (int j = 0; j < b; j++)
      if (s[i * b + j] == 'X') go[j] = true;
    i++;
    while (i < a) {
      for (int j = 0; j < b; j++) {
        go[j] = go[j] && (s[i * b + j] == 'X');
      }
      i++;
    }
    bool ok = false;
    for (auto j : go) ok |= j;
    if (ok) {
      cnt++;
      ans.push_back(a);
    }
  }
  cout << cnt << " ";
  for (int i : ans) {
    cout << i << "x" << 12 / i << ' ';
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tt = 1;
  cin >> tt;
  while (tt--) {
    solve();
  }
  return 0;
}
