#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int cnt = 0;
  string f = "";
  int arr[6][2] = {{2, 6}, {6, 2}, {3, 4}, {4, 3}};
  string out = "";
  for (int i = 0; i < n; i++) {
    string in;
    cin >> in;
    if (in.find("X") == string::npos) {
      f += "0\n";
      continue;
    }
    if (in.find("X") != string::npos) {
      out += "1x12 ";
      cnt++;
    }
    for (int j = 0; j < 6; j++) {
      if (in[j] == 'X' && in[j + 6] == 'X') {
        out += "2x6 ";
        cnt++;
        break;
      }
    }
    int counter;
    for (int j = 0; j < 4; j++) {
      counter = 0;
      for (int q = j; q < 12; q += 4) {
        if (in[q] == 'X') {
          counter++;
        }
      }
      if (counter == 3) {
        out += "3x4 ";
        cnt++;
        break;
      }
    }
    for (int j = 0; j < 3; j++) {
      counter = 0;
      for (int q = j; q < 12; q += 3) {
        if (in[q] == 'X') {
          counter++;
        }
      }
      if (counter == 4) {
        out += "4x3 ";
        cnt++;
        break;
      }
    }
    for (int j = 0; j < 2; j++) {
      counter = 0;
      for (int q = j; q < 12; q += 2) {
        if (in[q] == 'X') {
          counter++;
        }
      }
      if (counter == 6) {
        out += "6x2 ";
        cnt++;
        break;
      }
    }
    if (in.find("XXXXXXXXXXXX") != string::npos) {
      out += "12x1 ";
      cnt++;
    }
    ostringstream stream;
    stream << cnt;
    string s = stream.str();
    f += s;
    f += " ";
    f += out;
    f += "\n";
    out = "";
    cnt = 0;
  }
  cout << f;
  return 0;
}
