#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  char str[18];
  scanf("%d", &tc);
  while (tc--) {
    vector<int> v;
    scanf("%s", str);
    int s = 12;
    bool flag;
    int b;
    for (int a = 1; a <= 12; a++) {
      if (12 % a == 0) {
        b = 12 / a;
        flag = false;
        for (int i = 0; i < b; i++) {
          flag = true;
          for (int j = i; j < s; j += b) {
            if (str[j] != 'X') {
              flag = false;
              break;
            }
          }
          if (flag) break;
        }
        if (flag) {
          v.push_back(a);
        }
      }
    }
    printf("%d", v.size());
    for (int i = 0; i < v.size(); i++) {
      printf(" %dx%d", v[i], 12 / v[i]);
    }
    printf("\n");
  }
  return 0;
}
