#include <bits/stdc++.h>
using namespace std;
const int mxn = 200010;
const int mod = 1000000007;
bool seen[mxn] = {false};
int dp[mxn];
vector<int> adj[mxn];
bool cmp(int x, int y) { return (x > y); }
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    vector<pair<int, int> > res;
    string second;
    cin >> second;
    for (int i = 1; i <= 12; i++) {
      int v[13] = {0};
      if (12 % i == 0) {
        for (int l = 0; l < 12; l += 12 / i) {
          int c = 0;
          for (int k = l; k < 12 / i + l; k++) {
            if (second[k] == 'X') v[c]++;
            c++;
          }
        }
      }
      for (int j = 0; j < 13; j++)
        if (v[j] == i) {
          res.push_back(make_pair(i, 12 / i));
          break;
        }
    }
    cout << res.size() << ' ';
    for (int i = 0; i < res.size(); i++)
      cout << res[i].first << 'x' << res[i].second << ' ';
    cout << '\n';
  }
}
