#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int n;
string str[maxn];
vector<int> ans;
int tmp[] = {1, 2, 3, 4, 6, 12};
void solve(int id) {
  ans.clear();
  for (int i = 0; i < 6; ++i) {
    int rows = tmp[i];
    int cols = 12 / tmp[i];
    for (int j = 0; j < cols; ++j) {
      if (str[id][j] == 'O') {
        continue;
      }
      bool ok = true;
      for (int k = 0; k < rows; ++k) {
        if (str[id][j + k * cols] == 'O') {
          ok = false;
          break;
        }
      }
      if (ok) {
        ans.push_back(tmp[i]);
        break;
      }
    }
  }
  printf("%lu", ans.size());
  for (int i = 0; i < ans.size(); ++i) {
    printf(" %dx%d", ans[i], 12 / ans[i]);
  }
  printf("\n");
  return;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> str[i];
  }
  for (int i = 1; i <= n; ++i) {
    solve(i);
  }
  return 0;
}
