#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d\n", &n);
  char a[13];
  int r[6] = {1, 2, 3, 4, 6, 12};
  int c[6] = {12, 6, 4, 3, 2, 1};
  bool can[6] = {0};
  int sum = 0;
  bool is;
  string ss;
  char s;
  int nu = 1;
  for (int i = 0; i < n; ++i) {
    nu = 1;
    while ((s = getchar()) != '\n') a[nu++] = s;
    for (int j = 0; j < 6; ++j) can[j] = 0;
    sum = 0;
    for (int k = 0; k < 6; ++k) {
      is = 0;
      for (int c_ = 1; c_ <= c[k]; c_++) {
        if (a[c_] == 'X') {
          is = 1;
          for (int r_ = 1; r_ < r[k]; r_++)
            if (a[c_ + r_ * c[k]] != 'X') {
              is = 0;
              break;
            }
        } else
          is = 0;
        if (is) break;
      }
      if (is) {
        can[k] = 1;
        sum++;
      }
    }
    printf("%d", sum);
    if (sum == 0) {
      printf("\n");
      continue;
    }
    for (int j = 0; j < 6; ++j)
      if (can[j]) printf(" %dx%d", r[j], c[j]);
    printf("\n");
  }
  return 0;
}
