#include <bits/stdc++.h>
using namespace std;
int main() {
  int ___T, case_n = 1;
  scanf("%d ", &___T);
  while (___T-- > 0) {
    char s[15];
    scanf("%s", (s));
    vector<int> ha;
    for (int i = (1); i < (13); ++i) {
      if (12 % i == 0) {
        bool win = false;
        for (int j = 0; j < (12 / i); ++j) {
          bool suc = true;
          for (int k = 0; k < (i); ++k) {
            if (s[k * (12 / i) + j] == 'O') suc = false;
          }
          if (suc) win = true;
        }
        if (win) ha.push_back(i);
      }
    }
    printf("%d", ((int)(ha).size()));
    for (int i = 0; i < (((int)(ha).size())); ++i)
      printf(" %dx%d", ha[i], 12 / ha[i]);
    puts("");
  }
  return 0;
}
