#include <bits/stdc++.h>
int main() {
  int games;
  std::cin >> games;
  std::vector<std::string> squares;
  for (int i = 0; i < games; i++) {
    std::string board;
    std::cin >> board;
    squares.push_back(board);
  }
  for (int i = 0; i < games; i++) {
    std::string board = squares[i];
    std::string output = "";
    int nums = 0;
    if (!(board == "OOOOOOOOOOOO")) {
      output = output + " 1x12";
      nums++;
    }
    if ((board[0] == 'X' && board[6] == 'X') ||
        (board[1] == 'X' && board[7] == 'X') ||
        (board[2] == 'X' && board[8] == 'X') ||
        (board[3] == 'X' && board[9] == 'X') ||
        (board[4] == 'X' && board[10] == 'X') ||
        (board[5] == 'X' && board[11] == 'X')) {
      output = output + " 2x6";
      nums++;
    }
    if ((board[0] == 'X' && board[4] == 'X' && board[8] == 'X') ||
        (board[1] == 'X' && board[5] == 'X' && board[9] == 'X') ||
        (board[2] == 'X' && board[6] == 'X' && board[10] == 'X') ||
        (board[3] == 'X' && board[7] == 'X' && board[11] == 'X')) {
      output = output + " 3x4";
      nums++;
    }
    if ((board[0] == 'X' && board[3] == 'X' && board[6] == 'X' &&
         board[9] == 'X') ||
        (board[1] == 'X' && board[4] == 'X' && board[7] == 'X' &&
         board[10] == 'X') ||
        (board[2] == 'X' && board[5] == 'X' && board[8] == 'X' &&
         board[11] == 'X')) {
      output = output + " 4x3";
      nums++;
    }
    if ((board[0] == 'X' && board[2] == 'X' && board[4] == 'X' &&
         board[6] == 'X' && board[8] == 'X' && board[10] == 'X') ||
        (board[1] == 'X' && board[3] == 'X' && board[5] == 'X' &&
         board[7] == 'X' && board[9] == 'X' && board[11] == 'X')) {
      output = output + " 6x2";
      nums++;
    }
    if (board == "XXXXXXXXXXXX") {
      output = output + " 12x1";
      nums++;
    }
    std::cout << nums << output << std::endl;
  }
}
