#include <bits/stdc++.h>
using namespace std;
int t;
string s;
queue<int> q;
pair<int, int> fak[6] = {make_pair(1, 12), make_pair(2, 6), make_pair(3, 4),
                         make_pair(4, 3),  make_pair(6, 2), make_pair(12, 1)};
int main() {
  cin >> t;
  while (t--) {
    cin >> s;
    for (int i = 0; i < 6; i++) {
      bool boi[fak[i].second];
      for (int j = 0; j < fak[i].second; j++) {
        boi[j] = 1;
      }
      bool valid = 0;
      for (int x = 0; x < fak[i].first; x++) {
        for (int y = 0; y < fak[i].second; y++) {
          boi[y] &= (s[fak[i].second * x + y] == 'X');
        }
      }
      for (int j = 0; j < fak[i].second; j++) {
        valid |= boi[j];
      }
      if (valid) {
        q.push(i);
      }
    }
    cout << q.size();
    while (!q.empty()) {
      cout << ' ' << fak[q.front()].first << 'x' << fak[q.front()].second;
      q.pop();
    }
    cout << '\n';
  }
  return 0;
}
