#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[20];
  int b[20], c[20];
  int k, count, i, sum;
  cin >> k;
  while (k--) {
    count = sum = 0;
    cin >> a;
    for (i = 0; i < 12; i++) {
      if (a[i] == 'X')
        b[i] = 0;
      else
        b[i] = 1;
      sum += b[i];
    }
    if (sum != 12) {
      c[count++] = 1;
      if ((b[0] + b[6] == 0) || (b[1] + b[7] == 0) || (b[2] + b[8] == 0) ||
          (b[3] + b[9] == 0) || (b[4] + b[10] == 0) || (b[5] + b[11] == 0)) {
        c[count++] = 2;
      }
      if ((b[0] + b[4] + b[8] == 0) || (b[1] + b[5] + b[9] == 0) ||
          (b[2] + b[6] + b[10] == 0) || (b[3] + b[7] + b[11] == 0)) {
        c[count++] = 3;
      }
      if ((b[0] + b[3] + b[6] + b[9] == 0) ||
          (b[1] + b[4] + b[7] + b[10] == 0) ||
          (b[2] + b[5] + b[8] + b[11] == 0)) {
        c[count++] = 4;
      }
      if ((b[1] + b[5] + b[3] + b[7] + b[9] + b[11] == 0) ||
          (b[0] + b[2] + b[4] + b[6] + b[8] + b[10] == 0)) {
        c[count++] = 6;
      }
      if (sum == 0) c[count++] = 12;
    }
    cout << count;
    for (i = 0; i < count; i++) {
      cout << " " << c[i] << "x" << 12 / c[i];
    }
    cout << endl;
  }
  return 0;
}
