#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
int main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    v.clear();
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < 12; i++)
      if (s[i] == 'X') cnt++;
    if (cnt == 12) v.push_back(make_pair(12, 1));
    if (cnt > 0) v.push_back(make_pair(1, 12));
    cnt = 0;
    for (int i = 6; i < 12; i++)
      if (s[i] == 'X' && s[i - 6] == 'X') cnt++;
    if (cnt > 0) v.push_back(make_pair(2, 6));
    cnt = 0;
    for (int i = 0; i < 12; i += 2)
      if (s[i] == 'X') cnt++;
    int cnt2 = 0;
    for (int i = 1; i < 12; i += 2)
      if (s[i] == 'X') cnt2++;
    if (cnt == 6 || cnt2 == 6) v.push_back(make_pair(6, 2));
    cnt = 0;
    for (int i = 0; i < 12; i += 3)
      if (s[i] == 'X') cnt++;
    cnt2 = 0;
    for (int i = 1; i < 12; i += 3)
      if (s[i] == 'X') cnt2++;
    int cnt3 = 0;
    for (int i = 2; i < 12; i += 3)
      if (s[i] == 'X') cnt3++;
    if (cnt == 4 || cnt2 == 4 || cnt3 == 4) v.push_back(make_pair(4, 3));
    cnt = 0;
    for (int i = 0; i < 12; i += 4)
      if (s[i] == 'X') cnt++;
    cnt2 = 0;
    for (int i = 1; i < 12; i += 4)
      if (s[i] == 'X') cnt2++;
    cnt3 = 0;
    for (int i = 2; i < 12; i += 4)
      if (s[i] == 'X') cnt3++;
    int cnt4 = 0;
    for (int i = 3; i < 12; i += 4)
      if (s[i] == 'X') cnt4++;
    if (cnt == 3 || cnt2 == 3 || cnt3 == 3 || cnt4 == 3)
      v.push_back(make_pair(3, 4));
    sort(v.begin(), v.end());
    int l = v.size();
    if (l == 0) {
      cout << "0" << endl;
      continue;
    }
    cout << l << " ";
    for (int i = 0; i < l; i++) cout << v[i].first << "x" << v[i].second << " ";
    cout << endl;
  }
}
