#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  string tab[t];
  string s;
  int a = 0;
  for (int i = 0; i < t; i++) cin >> tab[i];
  for (int i = 0; i < t; i++) {
    s = "";
    a = 0;
    long long j = 0, c = 0;
    while (j < 12) {
      if (tab[i][j] == 'X' && a < 1) {
        s += "1x12 ";
        a++;
        c++;
      }
      j++;
    }
    a = 0;
    j = 0;
    while (j < 12) {
      if (tab[i][j] == 'X' && tab[i][j + 6] == 'X' && j < 6 && a < 1) {
        s += "2x6 ";
        a++;
        c++;
      }
      j++;
    }
    a = 0;
    j = 0;
    while (j < 12) {
      if (tab[i][j] == 'X' && tab[i][j + 4] == 'X' && tab[i][j + 8] == 'X' &&
          j < 4 && a < 1) {
        s += "3x4 ";
        a++;
        c++;
      }
      j++;
    }
    a = 0;
    j = 0;
    while (j < 12) {
      if (tab[i][j] == 'X' && tab[i][j + 3] == 'X' && tab[i][j + 6] == 'X' &&
          tab[i][j + 9] == 'X' && j < 3 && a < 1) {
        s += "4x3 ";
        a++;
        c++;
      }
      j++;
    }
    a = 0;
    j = 0;
    while (j < 12) {
      if (tab[i][j] == 'X' && tab[i][j + 2] == 'X' && tab[i][j + 4] == 'X' &&
          tab[i][j + 6] == 'X' && tab[i][j + 8] == 'X' &&
          tab[i][j + 10] == 'X' && j < 2 && a < 1) {
        s += "6x2 ";
        a++;
        c++;
      }
      j++;
    }
    a = 0;
    j = 0;
    if (tab[i] == "XXXXXXXXXXXX" && j < 1 && a < 1) {
      s += "12x1 ";
      a++;
      c++;
    }
    j++;
    if (s == "")
      cout << 0 << endl;
    else
      cout << c << " " << s << endl;
  }
  return 0;
}
