#include <bits/stdc++.h>
using namespace std;
int arr[6] = {1, 2, 3, 4, 6, 12};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string str;
    cin >> str;
    int sol[10];
    int a = 0, b = 0;
    int k = 0;
    for (int i = 0; i < 6; i++) {
      a = arr[i];
      b = 12 / a;
      int count = 0;
      for (int j = 0; j < b; j++) {
        count = 0;
        for (int i = 0; i < a; i++) {
          if (str[i * b + j] == 'X') count++;
        }
        if (count == a) {
          sol[k++] = a;
          break;
        }
      }
    }
    cout << k << " ";
    for (int i = 0; i < k; i++) {
      cout << sol[i] << "x" << 12 / sol[i] << " ";
    }
    cout << "\n";
  }
  return 0;
}
