#include <bits/stdc++.h>
using namespace std;
struct Node {
  int x;
  int y;
} data[100];
char s[14];
int Count = 0;
void judge() {
  int r, c, i, k, j, len;
  len = strlen(s + 1);
  for (c = 1; c <= 12; c++) {
    if (12 % c != 0) continue;
    r = 12 / c;
    for (k = 1; k <= c; k++) {
      for (j = k; j <= len; j += c) {
        if (s[j] != 'X') break;
      }
      if (j > len) {
        data[Count].x = r;
        data[Count].y = c;
        Count++;
        break;
      }
    }
  }
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      Count = 0;
      scanf("%s", s + 1);
      judge();
      printf("%d", Count);
      if (Count) {
        for (int i = Count - 1; i >= 0; i--)
          printf(" %dx%d", data[i].x, data[i].y);
      }
      printf("\n");
    }
  }
  return 0;
}
