#include <bits/stdc++.h>
using namespace std;
int x[20], m, n;
char p[20];
bool can(int a) {
  int k[12];
  memset(k, 0, sizeof(k));
  for (int i = 0; i < 12; i++)
    if (p[i] == 'X') k[i % (12 / a)]++;
  for (int i = 0; i < (12 / a); i++)
    if (k[i] == a) return true;
  return false;
}
void solve() {
  scanf("%s", p);
  int ans = 0;
  int ot[20];
  for (int i = 0; i < m; i++)
    if (can(x[i])) {
      ot[ans] = x[i];
      ans++;
    }
  cout << ans;
  for (int i = 0; i < ans; i++) cout << " " << ot[i] << "x" << 12 / ot[i];
  cout << endl;
  return;
}
int main() {
  x[0] = 1;
  x[1] = 2;
  x[2] = 3;
  x[3] = 4;
  x[4] = 6;
  x[5] = 12;
  m = 6;
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
