#include <bits/stdc++.h>
using namespace std;
void solve(const string& x) {
  vector<pair<string, bool>> ans{{"1x12", false}, {"2x6", false},
                                 {"3x4", false},  {"4x3", false},
                                 {"6x2", false},  {"12x1", false}};
  vector<pair<int, int>> vec{{1, 12}, {2, 6}, {3, 4}, {4, 3}, {6, 2}, {12, 1}};
  vector<vector<int>> str(12, vector<int>(12));
  int cnt = 0;
  for (int i = 0; i < vec.size(); i++) {
    int a = vec[i].first, b = vec[i].second;
    int pos = 0;
    for (int j = 0; j < a; j++) {
      for (int l = 0; l < b; l++) {
        char comp = x[pos];
        pos++;
        if (comp == 'X') {
          if (j == 0) {
            str[j][l] = 1;
            if (j == a - 1 && ans[i].second == false) {
              ans[i].second = true;
              cnt++;
            }
          } else if (str[j - 1][l] == 1) {
            str[j][l] = 1;
            if (j == a - 1 && ans[i].second == false) {
              ans[i].second = true;
              cnt++;
            }
          } else
            str[j][l] = 0;
        } else {
          str[j][l] = 0;
        }
      }
    }
  }
  cout << cnt << " ";
  for (auto i : ans)
    if (i.second) cout << i.first << " ";
  cout << endl;
}
int main() {
  string h;
  int n;
  while (cin >> n) {
    while (n--) {
      cin >> h;
      solve(h);
    }
  }
}
