#include <bits/stdc++.h>
using namespace std;
struct Pair {
  int rows, cols;
  Pair() {}
  Pair(int a, int b) : rows(a), cols(b) {}
};
ostream& operator<<(ostream& out, const Pair& p) {
  out << p.rows << "x" << p.cols;
  return out;
}
const int PAIRS_COUNT = 6;
Pair pairs[PAIRS_COUNT] = {Pair(1, 12), Pair(2, 6), Pair(3, 4),
                           Pair(4, 3),  Pair(6, 2), Pair(12, 1)};
string s;
bool isValidCol(int col, int colsCount) {
  for (int i = col; i < 12; i += colsCount)
    if (s[i] != 'X') {
      return false;
    }
  return true;
}
bool isValidPair(int pairIndex) {
  for (int i = 0; i < pairs[pairIndex].cols; i++)
    if (isValidCol(i, pairs[pairIndex].cols)) return true;
  return false;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> s;
    vector<int> validPairs;
    for (int i = 0; i < PAIRS_COUNT; i++)
      if (isValidPair(i)) validPairs.push_back(i);
    cout << validPairs.size();
    for (int i = 0; i < validPairs.size(); i++)
      cout << " " << pairs[validPairs[i]];
    cout << endl;
  }
  return 0;
}
