#include <bits/stdc++.h>
using namespace std;
char s[10010];
int ch[110][110];
bool ans[110];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    memset(ans, 0, sizeof(ans));
    scanf("%s", s);
    int cnt = 0;
    int l = strlen(s);
    for (int i = 1; i <= l; ++i) {
      if (l % i) continue;
      int cc = l / i;
      for (int j = 0; j < i; ++j) {
        for (int k = 0; k < cc; ++k) {
          ch[j][k] = s[j * cc + k];
        }
      }
      bool yes = false;
      for (int j = 0; j < cc; ++j) {
        yes = true;
        for (int k = 0; k < i; ++k) {
          if (ch[k][j] != 'X') {
            yes = false;
            break;
          }
        }
        if (yes == true) break;
      }
      if (yes == true) {
        ++cnt;
        ans[i] = true;
      }
    }
    printf("%d", cnt);
    for (int i = 1; i <= 100; ++i) {
      if (ans[i]) printf(" %dx%d", i, l / i);
    }
    puts("");
  }
  return 0;
}
