#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
bool isPrime(long long n) {
  if (n <= 1) return false;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
inline vector<int> sieve(int n) {
  vector<bool> isPrime(n + 1, true);
  for (int i = 2; i * i <= n; i++) {
    if (isPrime[i])
      for (int j = 2 * i; j <= n; j += i) {
        isPrime[j] = false;
      }
  }
  vector<int> primes;
  for (int i = 2; i <= n; i++)
    if (isPrime[i]) primes.push_back(i);
  return primes;
}
inline vector<bool> sieveQuery(int n) {
  vector<bool> isPrime(n + 1, true);
  for (int i = 2; i <= sqrt(n); i++) {
    if (isPrime[i])
      for (int j = 2 * i; j <= n; j += i) {
        isPrime[j] = false;
      }
  }
  return isPrime;
}
inline vector<long long> primeFactors(long long n) {
  vector<long long> F;
  for (long long i = 2LL; i * i <= n; i++) {
    while (n % i == 0) {
      F.push_back(i);
      n /= i;
    }
  }
  if (n > 1) F.push_back(n);
  return F;
}
inline vector<long long> unsorted_factors(long long n) {
  vector<long long> F;
  long long i = 1;
  for (; i * i < n; i++) {
    if (n % i == 0) {
      F.push_back(i);
      F.push_back(n / i);
    }
  }
  if (i * i == n) F.push_back(i);
  return F;
}
void shift_right(vector<int>& A, int x) {
  int n = A.size();
  x %= n;
  vector<int> B(n);
  for (int i = 0; i < n; i++) B[(i + x) % n] = A[i];
  A = B;
}
string itos(long long n) {
  string s;
  while (n) {
    s += char(n % 10 + 48);
    n /= 10;
  }
  reverse(s.begin(), s.end());
  return s;
}
int cnt_dig(int n) {
  int cnt = 0;
  while (n) {
    cnt++;
    n /= 10;
  }
  return cnt;
}
string binary(int n) {
  string bin;
  while (n) {
    bin += (n % 2 ? '1' : '0');
    n /= 2;
  }
  reverse(bin.begin(), bin.end());
  return bin;
}
bool isPalindrome(string& s) {
  for (int i = 0, j = s.size() - 1; i < j; i++, j--)
    if (s[i] != s[j]) return 0;
  return 1;
}
vector<int> bfs(const vector<vector<int> >& G, int start) {
  int distance = 0, maxDist = 0;
  queue<int> q;
  vector<bool> visited(G.size() + 8, false);
  vector<int> dist(G.size() + 1);
  visited[start] = true;
  q.push(start);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    visited[u] = true;
    for (int i : G[u])
      if (!visited[i]) {
        q.push(i);
        dist[i] = dist[u] + 1;
        maxDist = max(maxDist, dist[i]);
      }
  }
  vector<int> reqDist;
  for (int i = 2; i < G.size(); i++) {
    if (G[i].size() == 1) reqDist.push_back(dist[i]);
  }
  return reqDist;
}
class DSU {
 private:
  int parent[200009];
  int GroupSize[200009];

 public:
  DSU() {
    for (int i = 0; i < 200009; i++) {
      parent[i] = i;
      GroupSize[i] = 1;
    }
  }
  int findLeader(int i) {
    if (parent[i] == i) return i;
    return parent[i] = findLeader(parent[i]);
  }
  bool sameGroup(int x, int y) {
    int leader1 = findLeader(x);
    int leader2 = findLeader(y);
    return leader1 == leader2;
  }
  void merge(int x, int y) {
    int leader1 = findLeader(x);
    int leader2 = findLeader(y);
    if (leader1 == leader2) return;
    if (GroupSize[leader1] > GroupSize[leader2]) {
      parent[leader2] = leader1;
      GroupSize[leader1] += GroupSize[leader2];
    } else {
      parent[leader1] = leader2;
      GroupSize[leader2] += GroupSize[leader1];
    }
  }
  int getSize(int x) {
    int leader = findLeader(x);
    return GroupSize[leader];
  }
};
bool valid(string& s, int a, int b) {
  vector<string> A;
  for (int i = 0; i < 12 / b; i++) A.push_back(s.substr(i * b, 12 / a));
  bool CAN = 0;
  for (int i = 0; i < b; i++) {
    bool can = 1;
    for (int j = 0; j < a; j++) {
      if (A[j][i] == 'O') can = 0;
    }
    CAN = CAN || can;
  }
  return CAN;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int _t_ = 1;
  cin >> _t_;
  while (_t_--) {
    string s;
    cin >> s;
    int n = s.size();
    vector<pair<int, int> > A;
    if (valid(s, 1, 12)) A.push_back({1, 12});
    if (valid(s, 2, 6)) A.push_back({2, 6});
    if (valid(s, 3, 4)) A.push_back({3, 4});
    if (valid(s, 4, 3)) A.push_back({4, 3});
    if (valid(s, 6, 2)) A.push_back({6, 2});
    if (valid(s, 12, 1)) A.push_back({12, 1});
    cout << A.size() << ' ';
    for (pair<int, int> p : A) cout << p.first << "x" << p.second << ' ';
    cout << '\n';
  }
}
