#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6;
char str[10];
int a[10], b[10];
int map[13][13];
int main() {
  int cas, num, ans;
  scanf("%d", &cas);
  while (cas--) {
    num = ans = 0;
    int flag = 0;
    scanf("%s", str);
    int n = strlen(str);
    for (int i = 0; i < n; i++)
      if (str[i] == 'X') num++;
    if (num >= 1) {
      a[ans] = 1;
      b[ans++] = 12;
    }
    for (int i = 0; i < 6; i++) {
      if (str[i] == str[i + 6] && str[i] == 'X') flag = 1;
    }
    if (flag) a[ans] = 2, b[ans++] = 6;
    flag = 0;
    for (int i = 0; i < 4; i++) {
      if (str[i] == str[i + 4] && str[i] == str[i + 8] && str[i] == 'X')
        flag = 1;
    }
    if (flag) a[ans] = 3, b[ans++] = 4;
    flag = 0;
    for (int i = 0; i < 3; i++) {
      if (str[i] == str[i + 3] && str[i] == str[i + 6] &&
          str[i] == str[i + 9] && str[i] == 'X')
        flag = 1;
    }
    if (flag) a[ans] = 4, b[ans++] = 3;
    flag = 0;
    for (int i = 0; i < 2; i++) {
      if (str[i] == str[i + 2] && str[i] == str[i + 4] &&
          str[i] == str[i + 6] && str[i] == str[i + 8] &&
          str[i] == str[i + 10] && str[i] == 'X')
        flag = 1;
    }
    if (flag) a[ans] = 6, b[ans++] = 2;
    flag = 0;
    if (num == 12) a[ans] = 12, b[ans++] = 1;
    if (ans) {
      printf("%d", ans);
      for (int i = 0; i < ans; i++) {
        printf(" %dx%d", a[i], b[i]);
      }
      printf("\n");
    } else
      printf("0\n");
  }
  return 0;
}
