#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long z) {
  long long t = 1;
  while (y > 0) {
    if (y % 2) {
      t = (t * x) % z;
    }
    x = (x * x) % z;
    y /= 2;
  }
  return t;
}
const int _N = 3e5 + 11;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-6;
string st, h[6] = {"1x12", "2x6", "3x4", "4x3", "6x2", "12x1"};
int ans;
bool u[6];
bool check(int a, int b) {
  int i, w, j;
  for (i = 0; i < b; i++) {
    for (j = i; j < 12; j += b)
      if (st[j] == 'O') break;
    if (j >= 12) return 1;
  }
  return 0;
}
void solve() {
  int i, j;
  cin >> st;
  memset(u, 0, sizeof u);
  ans = 0;
  if (check(1, 12)) {
    u[0] = 1;
    ans++;
  }
  if (check(2, 6)) {
    u[1] = 1;
    ans++;
  }
  if (check(3, 4)) {
    u[2] = 1;
    ans++;
  }
  if (check(4, 3)) {
    u[3] = 1;
    ans++;
  }
  if (check(6, 2)) {
    u[4] = 1;
    ans++;
  }
  if (check(12, 1)) {
    u[5] = 1;
    ans++;
  }
  printf("%d ", ans);
  for (i = 0; i < 6; i++)
    if (u[i]) cout << h[i] << " ";
  printf("\n");
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
}
