#include <bits/stdc++.h>
long long int mod = 1000000007;
using namespace std;
int a[] = {1, 2, 3, 4, 6, 12};
int b[] = {12, 6, 4, 3, 2, 1};
int main() {
  int t;
  cin >> t;
  string s;
  for (int i = 0; i < t; i++) {
    cin >> s;
    int ans[6] = {0};
    int ct = 0;
    for (int i = 0; i < 12; i++) {
      if (s[i] == 'X') {
        ct++;
      }
    }
    if (ct == 12) {
      cout << 6 << " ";
      for (int i = 0; i < 6; i++) {
        cout << a[i] << "x" << b[i] << " ";
      }
      cout << endl;
      continue;
    }
    if (ct == 0) {
      cout << 0 << endl;
      continue;
    }
    if (ct >= 1) {
      ans[0] = 1;
      ct = 1;
    }
    for (int i = 0; i < 6; i++) {
      if (s[i] == 'X' && s[i + 6] == 'X') {
        ans[1] = 1;
        ct++;
        break;
      }
    }
    for (int i = 0; i <= 3; i++) {
      if (s[i] == 'X' && s[i + 4] == 'X' && s[i + 8] == 'X') {
        ans[2] = 1;
        ct++;
        break;
      }
    }
    for (int i = 0; i <= 2; i++) {
      if (s[i] == 'X' && s[i + 3] == 'X' && s[i + 6] == 'X' &&
          s[i + 9] == 'X') {
        ans[3] = 1;
        ct++;
        break;
      }
    }
    for (int i = 0; i <= 1; i++) {
      if (s[i] == 'X' && s[i + 2] == 'X' && s[i + 4] == 'X' &&
          s[i + 6] == 'X' && s[i + 8] == 'X' && s[i + 10] == 'X') {
        ans[4] = 1;
        ct++;
        break;
      }
    }
    cout << ct << " ";
    for (int i = 0; i <= 4; i++) {
      if (ans[i] == 1) {
        cout << a[i] << "x" << b[i] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
