#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  char str[13];
  bool yes[13];
  int geshu = 0;
  cin >> t;
  for (int i = 0; i < t; i++) {
    geshu = 0;
    memset(yes, false, sizeof(yes));
    cin >> str;
    for (int i = 0; i < 12; i++) {
      if (str[i] == 'X') {
        yes[1] = true;
        geshu++;
        break;
      }
    }
    for (int i = 0; i < 6; i++) {
      if (str[i] == 'X' && str[i + 6] == 'X') {
        yes[2] = true;
        geshu++;
        break;
      }
    }
    for (int i = 0; i < 4; i++) {
      if (str[i] == 'X' && str[i + 4] == 'X' && str[i + 8] == 'X') {
        yes[3] = true;
        geshu++;
        break;
      }
    }
    for (int i = 0; i < 3; i++) {
      if (str[i] == 'X' && str[i + 3] == 'X' && str[i + 6] == 'X' &&
          str[i + 9] == 'X') {
        yes[4] = true;
        geshu++;
        break;
      }
    }
    for (int i = 0; i < 2; i++) {
      if (str[i] == 'X' && str[i + 2] == 'X' && str[i + 4] == 'X' &&
          str[i + 6] == 'X' && str[i + 8] == 'X' && str[i + 10] == 'X') {
        yes[6] = true;
        geshu++;
        break;
      }
    }
    yes[12] = true;
    geshu++;
    for (int i = 0; i < 12; i++) {
      if (str[i] != 'X') {
        yes[12] = false;
        geshu--;
        break;
      }
    }
    cout << geshu;
    for (int i = 1; i <= 12; i++) {
      if (yes[i] == true) cout << " " << i << "x" << 12 / i;
    }
    cout << endl;
  }
}
