#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k, f[6] = {1, 2, 3, 4, 6, 12}, ans;
  char s[15];
  vector<int> a;
  bool flag, col;
  cin >> n;
  while (n--) {
    ans = 0;
    a.clear();
    cin >> s;
    for (k = 0; k < 6; k++) {
      col = 0;
      for (j = 0; j < 12 / f[k]; j++) {
        flag = 1;
        for (i = 0; i < f[k]; i++) {
          if (s[i * 12 / f[k] + j] != 'X') {
            flag = 0;
            break;
          }
        }
        if (flag) {
          col = 1;
          break;
        }
      }
      if (col) {
        ans++;
        a.push_back(f[k]);
      }
    }
    cout << ans;
    for (i = 0; i < a.size(); i++) cout << ' ' << a[i] << 'x' << 12 / a[i];
    cout << endl;
  }
  return 0;
}
