#include <bits/stdc++.h>
using namespace std;
string str;
void solve() {
  int A = 0;
  int ans[10];
  for (int i = 1; i <= 12; i++) {
    if (12 % i == 0) {
      int x = 12 / i, y;
      for (int k = 0; k < x; k++) {
        y = 1;
        for (int j = k; j < 12; j += x)
          if (str[j] == 'O') y = 0;
        if (y != 0) {
          ans[A++] = i;
          break;
        }
      }
    }
  }
  cout << A << " ";
  for (int i = 0; i < A; i++) {
    cout << ans[i] << 'x' << 12 / ans[i] << " ";
  }
}
int main() {
  int t, n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str;
    solve();
    cout << endl;
  }
}
