#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    char a[15];
    cin >> a;
    int flag1 = 0, flag6 = 1, sum = 0;
    for (int i = 0; i < 12; i++)
      if (a[i] == 'X')
        flag1 = 1;
      else
        flag6 = 0;
    if (flag1) sum++;
    if (flag6) sum++;
    int flag2 = 0;
    for (int i = 0; i < 6; i++)
      if (a[i] == 'X' && a[i + 6] == 'X') {
        sum++;
        flag2 = 1;
        break;
      }
    int flag3 = 0;
    for (int i = 0; i < 4; i++)
      if (a[i] == 'X' && a[i + 4] == 'X' && a[i + 8] == 'X') {
        sum++;
        flag3 = 1;
        break;
      }
    int flag4 = 0, flag5 = 0;
    for (int i = 0; i < 3; i++)
      if (a[i] == 'X' && a[i + 3] == 'X' && a[i + 6] == 'X' &&
          a[i + 9] == 'X') {
        sum++;
        flag4 = 1;
        break;
      }
    for (int i = 0; i < 2; i++)
      if (a[i] == 'X' && a[i + 2] == 'X' && a[i + 4] == 'X' &&
          a[i + 6] == 'X' && a[i + 8] == 'X' && a[i + 10] == 'X') {
        sum++;
        flag5 = 1;
        break;
      }
    cout << sum;
    if (flag1) cout << " 1x12";
    if (flag2) cout << " 2x6";
    if (flag3) cout << " 3x4";
    if (flag4) cout << " 4x3";
    if (flag5) cout << " 6x2";
    if (flag6) cout << " 12x1";
    cout << endl;
  }
  return 0;
}
