#include <bits/stdc++.h>
using namespace std;
int nTest;
int main() {
  for (scanf("%d", &nTest); nTest; nTest--) {
    char line[20];
    scanf("%s", line);
    vector<pair<int, int> > ret;
    ret.clear();
    for (int a = 1; a <= 12; a++)
      if (12 % a == 0) {
        int b = 12 / a;
        bool ok = 0;
        for (int i = 0; i < b; i++) {
          bool tok = 1;
          for (int j = i; j < 12; j += b)
            if (line[j] != 'X') {
              tok = 0;
              break;
            }
          if (tok) {
            ok = 1;
            break;
          }
        }
        if (ok) ret.push_back(make_pair(a, b));
      }
    printf("%d ", ret.size());
    for (int i = 0; i < ret.size(); i++)
      printf("%dx%d ", ret[i].first, ret[i].second);
    printf("\n");
  }
  return 0;
}
