#include <bits/stdc++.h>
using namespace std;
bool res[6];
int x_idx[6] = {1, 2, 3, 4, 6, 12};
int y_idx[6] = {12, 6, 4, 3, 2, 1};
int findsol(string s) {
  bool flag;
  int count = 0;
  for (int i = 0; i < 6; i++) {
    int j = 0;
    while (j < y_idx[i]) {
      flag = true;
      for (int k = j; k < 12; k += y_idx[i]) {
        if (s[k] != 'X') {
          flag = false;
          break;
        }
      }
      if (flag) {
        res[i] = true;
        count++;
        break;
      }
      ++j;
    }
  }
  return count;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    for (int i = 0; i < 6; ++i) res[i] = false;
    cout << findsol(s) << " ";
    for (int i = 0; i < 6; ++i) {
      if (res[i] == true) {
        cout << x_idx[i] << "x" << y_idx[i] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
