#include <bits/stdc++.h>
using namespace std;
bool check(string cards, int a, int b) {
  bool isValid = false;
  for (int j = 0; j < b && !isValid; j++) {
    int shift = 0;
    isValid = true;
    for (int i = 0; i < a; i++, shift += b) {
      if (cards[shift + j] != 'X') {
        isValid = false;
        break;
      }
    }
  }
  return isValid;
}
int main() {
  int t;
  vector<string> ways;
  cin >> t;
  for (int i = 0; i < t; i++) {
    string cards;
    cin >> cards;
    if (check(cards, 1, 12)) ways.push_back("1x12");
    if (check(cards, 2, 6)) ways.push_back("2x6");
    if (check(cards, 3, 4)) ways.push_back("3x4");
    if (check(cards, 4, 3)) ways.push_back("4x3");
    if (check(cards, 6, 2)) ways.push_back("6x2");
    if (check(cards, 12, 1)) ways.push_back("12x1");
    cout << ways.size() << " ";
    vector<string>::iterator itr = ways.begin();
    for (; itr != ways.end(); itr++) cout << *itr << " ";
    cout << endl;
    ways.clear();
  }
  cout << endl;
  return 0;
}
