#include <bits/stdc++.h>
using namespace std;
char in[20];
int ans[10], p;
bool judge(int a) {
  int b = 12 / a;
  for (int i = 0; i < b; ++i) {
    int j;
    char ch;
    ch = in[b];
    for (j = 0; j < a; ++j) {
      if (in[j * b + i] == 'O') break;
    }
    if (j == a) return true;
  }
  return false;
}
void solve() {
  p = 0;
  for (int i = 1; i <= 12; ++i) {
    if (12 % i != 0) continue;
    if (judge(i)) ans[p++] = i;
  }
  printf("%d ", p);
  for (int i = 0; i < p; ++i) {
    printf("%dx%d", ans[i], 12 / ans[i]);
    if (i < p - 1) printf(" ");
  }
  printf("\n");
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%s", in);
    solve();
  }
  return 0;
}
