#include <bits/stdc++.h>
const int N = 20;
char get[N][N];
char s[N];
bool w[N][N];
int main() {
  int T;
  scanf("%d", &T);
  while (T-- > 0) {
    memset(w, 0, sizeof w);
    scanf("%s", s + 1);
    int cnt = 0;
    for (int i = 1; i <= 12; ++i)
      if (12 % i == 0) {
        int j = 12 / i;
        for (int k = 1; k <= j; ++k) {
          bool f = true;
          char c = s[k];
          if (c == 'O') continue;
          for (int z = 1; z <= i; ++z)
            if (s[(z - 1) * j + k] != c) f = false;
          if (f && !w[i][j]) {
            w[i][j] = true;
            ++cnt;
          }
        }
      }
    printf("%d", cnt);
    for (int i = 1; i <= 12; ++i)
      if (12 % i == 0) {
        if (w[i][12 / i]) printf(" %dx%d", i, 12 / i);
      }
    puts("");
  }
  return 0;
}
