#include <bits/stdc++.h>
struct succ {
  int c, d;
};
using namespace std;
int f[8] = {2, 3, 4, 6, 12};
int main() {
  int t;
  cin >> t;
  cin.get();
  while (t--) {
    int a[15] = {0}, flag = 0;
    string s;
    vector<succ> v;
    getline(cin, s);
    for (int i = 0; i < 12; i++)
      if (s[i] == 'X') {
        a[i + 1] = 1;
        flag = 1;
      }
    succ p;
    if (flag) {
      p.c = 1;
      p.d = 12;
      v.push_back(p);
    }
    for (int i = 0; i < 5; i++) {
      flag = 0;
      int k = 12 / f[i], total;
      for (int j = 1; j <= k; j++) {
        total = 1;
        if (a[j] == 1)
          for (int e = j + k; e <= 12; e += k)
            if (a[e] == 1) total++;
        if (total == f[i] && a[j] == 1) flag = 1;
      }
      if (flag) {
        p.c = f[i];
        p.d = 12 / p.c;
        v.push_back(p);
      }
    }
    int vol = v.size();
    cout << vol;
    for (int i = 0; i < vol; i++) {
      cout << ' ' << v[i].c << 'x' << v[i].d;
    }
    cout << endl;
  }
  return 0;
}
