#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, ans = 0;
  scanf("%d", &N);
  while (N--) {
    ans = 0;
    int b[12][12] = {0}, c[6] = {0};
    char a[12];
    int x = 0;
    for (int i = 0; i < 12; i++) scanf(" %c", &a[i]);
    for (int i = 0; i < 12; i++) {
      if (a[i] == 'X') {
        ans++;
        c[x] = 1;
        x++;
        break;
      }
    }
    for (int i = 0; i < 6; i++) {
      if (a[i] == 'X' && a[i + 6] == 'X') {
        ans++;
        c[x] = 2;
        x++;
        break;
      }
    }
    for (int i = 0; i < 4; i++) {
      if (a[i] == 'X' && a[i + 4] == 'X' && a[i + 8] == 'X') {
        ans++;
        c[x] = 3;
        x++;
        break;
      }
    }
    for (int i = 0; i < 3; i++) {
      if (a[i] == 'X' && a[i + 3] == 'X' && a[i + 6] == 'X' &&
          a[i + 9] == 'X') {
        ans++;
        c[x] = 4;
        x++;
        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') {
        ans++;
        c[x] = 6;
        x++;
        break;
      }
    }
    int y = 0;
    for (int i = 0; i < 12; i++) {
      if (a[i] == 'X') y++;
    }
    if (y == 12) {
      ans++;
      c[x++] = 12;
    }
    if (ans != 0)
      printf("%d ", ans);
    else
      printf("0\n");
    for (int i = 0; i < ans; i++) {
      if (i != ans - 1)
        printf("%dx%d ", c[i], 12 / c[i]);
      else
        printf("%dx%d\n", c[i], 12 / c[i]);
    }
  }
  return 0;
}
