#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i, l, j, k, flag, temp, b[20], ans, a[] = {1, 2, 3, 4, 6, 12}, row,
                                             col;
  string s;
  cin >> t;
  while (t--) {
    memset(b, 0, sizeof(b));
    ans = 0;
    cin >> s;
    l = s.length();
    for (i = 0; i < 6; i++) {
      flag = 1;
      col = a[i];
      row = 12 / a[i];
      for (j = 0; j < col; j++) {
        flag = 1;
        for (k = j; k < 12; k += col) {
          if (s[k] != 'X') {
            flag = 0;
            break;
          }
        }
        if (flag) {
          ans++;
          b[i] = a[i];
          break;
        }
      }
    }
    cout << ans << " ";
    for (i = 5; i >= 0; i--) {
      if (b[i]) {
        cout << 12 / b[i] << "x" << b[i] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
