#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2, s3, s4, s5;
  int n, i, j, k = 0, p = 1, d[4];
  char a[12];
  for (i = 0; i < 4; i++) d[i] = 1;
  cin >> n;
  for (i = 0; i < n; i++) {
    for (j = 0; j < 12; j++) cin >> a[j];
    for (j = 0; j < 12; j++)
      if (a[j] == 'X') k++;
    if (k == 0)
      cout << "0" << endl;
    else {
      for (j = 0; j < 12; j++) {
        if (a[j] == 'X') {
          if ((a[j + 2] == 'X') && (a[j + 4] == 'X') && (a[j + 6] == 'X') &&
              (a[j + 8] == 'X') && (a[j + 10] == 'X') && (d[0] == 1)) {
            p++;
            s1 = " 6x2";
            d[0] = 0;
          }
          if ((a[j + 3] == 'X') && (a[j + 6] == 'X') && (a[j + 9] == 'X') &&
              (d[1] == 1)) {
            p++;
            s2 = " 4x3";
            d[1] = 0;
          }
          if ((a[j + 4] == 'X') && (a[j + 8] == 'X') && (d[2] == 1)) {
            p++;
            s3 = " 3x4";
            d[2] = 0;
          }
          if ((a[j + 6] == 'X') && (d[3] == 1)) {
            p++;
            s4 = " 2x6";
            d[3] = 0;
          }
        }
      }
      if (k == 12) {
        s5 = " 12x1";
        k = 0;
        p++;
      }
      cout << p << " 1x12" << s4 + s3 + s2 + s1 + s5 << endl;
      k = 0, p = 1;
      for (j = 0; j < 4; j++) d[j] = 1;
      s1 = "", s2 = "", s3 = "", s4 = "", s5 = "";
    }
  }
  return 0;
}
