#include <bits/stdc++.h>
using namespace std;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const long long int Inf = 1LL << 62;
char mat[13][13];
bool solve(string str, int a, int b) {
  int pos = 0;
  for (int i = 1; i <= a; i++) {
    for (int j = 1; j <= b; j++) {
      mat[i][j] = str[pos++];
    }
  }
  for (int j = 1; j <= b; j++) {
    bool f = 1;
    for (int i = 1; i <= a; i++) {
      f &= (mat[i][j] == 'X');
    }
    if (f) {
      return 1;
    }
  }
  return 0;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    string str;
    cin >> str;
    vector<pair<int, int>> vec;
    for (int i = 1; i <= 12; i++) {
      if (12 % i == 0) {
        if (solve(str, i, 12 / i)) {
          vec.push_back({i, 12 / i});
        }
      }
    }
    cout << vec.size();
    for (pair<int, int> x : vec) {
      cout << " " << x.first << "x" << x.second;
    }
    cout << endl;
  }
  return 0;
}
