#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > temp;
int main() {
  int t;
  cin >> t;
  while (t--) {
    temp.clear();
    char a[13];
    for (int i = 1; i <= 12; i++) {
      cin >> a[i];
    }
    int arr[] = {1, 2, 3, 4, 6, 12};
    for (int i = 0; i < 6; i++) {
      int dp[13] = {0};
      int x = arr[i];
      int y = 12 / x;
      for (int j = 1; j <= y; j++) {
        if (a[j] == 'X') dp[j] = 1;
      }
      for (int j = y + 1; j <= 12; j++) {
        if (a[j] == 'X') dp[j] = dp[j - y] + 1;
      }
      for (int j = 12; j >= 12 - y + 1; j--) {
        if (dp[j] == x) {
          pair<int, int> p = {x, y};
          temp.push_back(p);
          break;
        }
      }
    }
    cout << temp.size() << " ";
    for (auto it : temp) {
      cout << it.first << "x" << it.second << " ";
    }
    cout << endl;
  }
  return 0;
}
