#include <bits/stdc++.h>
using namespace std;
char s[20];
int main() {
  int n, i;
  scanf("%d", &n);
  while (n--) {
    scanf("%s", s);
    int cnt = 0;
    int a[13] = {0};
    for (i = 1; i <= 12; ++i)
      if (12 % i == 0) {
        int ok = 1;
        for (int j = 0; j < i; ++j) {
          ok = 1;
          for (int k = 0; i * k + j < 12; ++k)
            if (s[i * k + j] != 'X') {
              ok = 0;
              break;
            }
          if (ok) break;
        }
        if (ok) {
          ++cnt;
          a[i] = 1;
        }
      }
    cout << cnt;
    for (i = 12; i; --i)
      if (a[i]) printf(" %dx%d", 12 / i, i);
    puts("");
  }
  return 0;
}
