#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int div[] = {1, 2, 3, 4, 6, 12};
  while (t--) {
    string s;
    cin >> s;
    vector<pair<int, int> > dimen;
    int n, m;
    int i, j, k;
    for (k = 0; k < 6; k++) {
      n = div[k];
      m = 12 / n;
      for (j = 0; j < m; j++) {
        for (i = 0; i < n; i++) {
          if (s[i * m + j] != 'X') break;
        }
        if (i == n) {
          dimen.push_back(make_pair(n, m));
          break;
        }
      }
    }
    cout << dimen.size() << " ";
    for (int i = 0; i < dimen.size(); i++)
      cout << dimen[i].first << "x" << dimen[i].second << " ";
    cout << endl;
  }
  return 0;
}
