#include <bits/stdc++.h>
using namespace std;
int max(int a, int b) { return a > b ? a : b; }
int min(int a, int b) { return a < b ? a : b; }
int main() {
  int n, i, j, k, l;
  char s[20];
  int ans[20], cnt;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", s);
    cnt = 0;
    for (j = 1; j <= 12; j++) {
      if (12 % j != 0) continue;
      int tmp = 0;
      for (k = 0; k < j; k++) {
        for (l = 0; k + l < 12; l += j) {
          if (s[k + l] == 'O') break;
        }
        if (k + l >= 12) {
          tmp = 1;
          break;
        }
      }
      if (tmp) {
        ans[cnt] = j;
        cnt++;
      }
    }
    printf("%d", cnt);
    for (j = cnt - 1; j >= 0; j--) {
      printf(" %dx%d", 12 / ans[j], ans[j]);
    }
    puts("");
  }
}
