#include <bits/stdc++.h>
using namespace std;
string s[200];
int main() {
  int t, i, a[10], b[10], j, k, q, p;
  cin >> t;
  a[0] = 12;
  a[1] = 6;
  a[2] = 4;
  a[3] = 3;
  a[4] = 2;
  a[5] = 1;
  for (i = 0; i < t; i++) cin >> s[i];
  for (i = 0; i < t; i++) {
    for (j = 0; j < 6; j++) {
      b[j] = 0;
      for (k = 0; k < a[j]; k++) {
        q = 0;
        for (p = k; p < 12; p += a[j])
          if (s[i][p] == 'O') q = 1;
        if (q == 0) b[j] = 1;
      }
    }
    q = 0;
    for (j = 0; j < 6; j++)
      if (b[j] == 1) q++;
    cout << q;
    for (j = 0; j < 6; j++)
      if (b[j] == 1) cout << " " << 12 / a[j] << "x" << a[j];
    cout << "\n";
  }
  return 0;
}
