#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  int a[] = {1, 2, 3, 4, 6, 12};
  int b[] = {12, 6, 4, 3, 2, 1};
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int ans[20];
    int count = 0, n = 0, no;
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < b[i]; j++) {
        no = 0;
        for (int k = 0; k < a[i]; k++) {
          if (s[j + k * b[i]] != 'X') {
            no = 1;
            break;
          }
        }
        if (!no) {
          ans[count++] = i;
          n++;
          break;
        }
      }
    }
    cout << n << " ";
    for (int i = 0; i < n; i++) {
      cout << a[ans[i]] << "x" << b[ans[i]] << " ";
    }
    cout << endl;
  }
}
