#include <bits/stdc++.h>
using namespace std;
int n, k, x, A[1000005], m;
string cad;
long long pot[51];
pair<int, int> M[20];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  while (n--) {
    cin >> cad;
    int res = 0;
    bool B[16];
    for (int i = 1; i <= 12; i++)
      for (int j = 1; j <= 12; j++)
        if (i * j == 12) {
          memset(B, 1, sizeof(B));
          int cnt = 0;
          for (int k = 0; k < i; k++)
            for (int w = 0; w < j; w++, cnt++) {
              if (cad[cnt] == 'X') {
                B[w] &= 1;
              } else
                B[w] &= 0;
            }
          for (int w = 0; w < j; w++)
            if (B[w]) {
              M[res++] = make_pair(i, j);
              break;
            }
        }
    sort(M, M + res);
    cout << res << " ";
    for (int i = 0; i < res; i++)
      cout << M[i].first << "x" << M[i].second << " ";
    cout << endl;
  }
  return 0;
}
