#include <bits/stdc++.h>
using namespace std;
char tmp[20];
vector<int> rjesenja;
bool moze(int a, int b) {
  for (int i = 0; i < b; ++i) {
    bool ok = true;
    for (int j = 0; j < a; ++j) {
      if (tmp[j * b + i] != 'X') {
        ok = false;
      }
    }
    if (ok) return true;
  }
  return false;
}
int main() {
  int t;
  scanf("%d", &t);
  for (int test = 0; test < t; ++test) {
    rjesenja.clear();
    scanf("%s", tmp);
    for (int a = 1; a <= 12; ++a) {
      if (12 % a != 0) continue;
      int b = 12 / a;
      if (moze(a, b)) {
        rjesenja.push_back(a);
      }
    }
    printf("%d", (int)rjesenja.size());
    for (int i = 0; i < (int)rjesenja.size(); ++i)
      printf(" %dx%d", rjesenja[i], 12 / rjesenja[i]);
    printf("\n");
  }
  return 0;
}
