#include <bits/stdc++.h>
using namespace std;
bool gana(int a, int b, string cad) {
  bool gana1 = false;
  int x = 0;
  for (int i = 0; i < b; i++) {
    gana1 = false;
    x = 0;
    for (int j = i; j < 12; j = j + b) {
      if (cad[j] == 'X') x++;
    }
    if (x == a) {
      gana1 = true;
      break;
    }
  }
  return gana1;
}
int main() {
  int n;
  string cad;
  cin >> n;
  while (n--) {
    string res = "";
    cin >> cad;
    int cont = 0;
    for (int i = 0; i < cad.size(); i++) {
      if (cad[i] == 'X') {
        res += "1x12 ";
        cont++;
        break;
      }
    }
    if (gana(2, 6, cad)) {
      res += "2x6 ";
      cont++;
    }
    if (gana(3, 4, cad)) {
      res += "3x4 ";
      cont++;
    }
    if (gana(4, 3, cad)) {
      res += "4x3 ";
      cont++;
    }
    if (gana(6, 2, cad)) {
      res += "6x2 ";
      cont++;
    }
    if (cad == "XXXXXXXXXXXX") {
      res += "12x1";
      cont++;
    }
    cout << cont << " " << res << endl;
  }
  return 0;
}
