#include <bits/stdc++.h>
using namespace std;
string input;
bool check(int h, int w) {
  for (int j = 0; j < w; j++) {
    bool all_x = true;
    for (int i = 0; i < h; i++) {
      int index = i * w + j;
      if (input[index] != 'X') {
        all_x = false;
        break;
      }
    }
    if (all_x) {
      return true;
    }
  }
  return false;
}
int main() {
  int cases;
  scanf("%d", &cases);
  for (int e = 0; e < cases; e++) {
    cin >> input;
    vector<int> dump;
    for (int a = 1; a <= 12; a++) {
      if (12 % a == 0) {
        if (check(a, 12 / a)) {
          dump.push_back(a);
        }
      }
    }
    printf("%d", dump.size());
    for (auto el : dump) {
      printf(" %dx%d", el, 12 / el);
    }
    printf("\n");
  }
  return 0;
}
