#include <bits/stdc++.h>
using namespace std;
char s[100];
int rec[100], mark[100];
int main() {
  int T, tc, ans, a, b, i, now;
  cin >> T;
  tc = 0;
  while (tc < T) {
    tc++;
    scanf("%s", s);
    ans = 0;
    memset(rec, 0, sizeof(rec));
    for (a = 1; a <= 12; a++) {
      if (12 % a != 0) continue;
      b = 12 / a;
      memset(mark, 0, sizeof(mark));
      for (i = 0; i < 12; i++) {
        if (s[i] == 'O') mark[i % b] = 1;
      }
      now = 0;
      for (i = 0; i < b; i++) now += mark[i];
      if (now < b) {
        ans++;
        rec[a] = 1;
      }
    }
    printf("%d", ans);
    for (a = 1; a <= 12; a++) {
      if (rec[a] == 1) {
        printf(" %dx%d", a, 12 / a);
      }
    }
    printf("\n");
  }
  return 0;
}
