#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  int arr[12];
  string s;
  cin >> t;
  while (t--) {
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 12; i++) arr[i] = 0;
    for (int i = 1; i <= 12; i++) {
      if (12 % i != 0) continue;
      int b = 12 / i, x = -1, flag = 1;
      for (int j = 0; j < b; j++) {
        int y = j, flag = 1;
        for (int k = 1; k <= i; k++) {
          if (s[y] != 'X') {
            flag = 0;
            break;
          }
          y += b;
        }
        if (flag == 1) {
          ans++;
          arr[i - 1] = 1;
          break;
        }
      }
    }
    cout << ans << " ";
    for (int i = 0; i < 12; i++) {
      if (arr[i] == 1 && 12 % (i + 1) == 0)
        cout << i + 1 << 'x' << 12 / (i + 1) << " ";
    }
    cout << "\n";
  }
}
