#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> s;
    vector<int> v;
    v.clear();
    int i;
    for (i = 0; i < 12; i++) {
      if (s[i] == 'X') {
        v.push_back(1);
        break;
      }
    }
    char st[100];
    bool flag;
    flag = false;
    memset(st, 0, sizeof(st));
    int j, k;
    for (j = 0; j < 2; j++) {
      for (i = j, k = 0; i < 12; i += 2, k++) {
        st[k] = s[i];
        st[k + 1] = '\0';
        if (strcmp(st, "XXXXXX") == 0) {
          v.push_back(6);
          flag = true;
        }
        if (flag) break;
      }
    }
    flag = false;
    memset(st, 0, sizeof(st));
    for (j = 0; j < 3; j++) {
      for (i = j, k = 0; i < 12; i += 3, k++) {
        st[k] = s[i];
        st[k + 1] = '\0';
        if (strcmp(st, "XXXX") == 0) {
          v.push_back(4);
          flag = true;
        }
        if (flag) break;
      }
    }
    flag = false;
    memset(st, 0, sizeof(st));
    for (j = 0; j < 4; j++) {
      for (i = j, k = 0; i < 12; i += 4, k++) {
        st[k] = s[i];
        st[k + 1] = '\0';
        if (strcmp(st, "XXX") == 0) {
          v.push_back(3);
          flag = true;
        }
        if (flag) break;
      }
    }
    flag = false;
    memset(st, 0, sizeof(st));
    for (j = 0; j < 6; j++) {
      for (i = j, k = 0; i < 12; i += 6, k++) {
        st[k] = s[i];
        st[k + 1] = '\0';
        if (strcmp(st, "XX") == 0) {
          v.push_back(2);
          flag = true;
        }
        if (flag) break;
      }
    }
    if (s == "XXXXXXXXXXXX") {
      v.push_back(12);
    }
    sort(v.begin(), v.end());
    cout << v.size() << ' ';
    for (i = 0; i < v.size(); i++) {
      cout << v[i] << 'x' << 12 / v[i] << ' ';
    }
    cout << endl;
  }
}
