#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <cstdlib>
#include <utility>
#include<iostream>
#include <iterator>
#include <set>
typedef long long ll;
#define fi first
#define se second
#define PB(a) push_back(a);
#define INF = 1000000000;
#define REP(i,n) for (int i = 0; i < n; i++)
#define REPI(i,n) for (int i = 1; i <= n; i++)
#define REPN(i,n) for (int i = n-1; i >= 0; i--)
#define REPF(j,i,n) for (int j = i; j < n; j++)
#define LL long long
#define PI pair<int,int>
#define PL pair<long,long>
#define vi vector<int>
#define MAXN 100005
//int gcd(int a,int b){ return b == 0 ? a : gcd(b,a%b);}
//int lcm(int a,int b){ return a * (b/gcd(a,b)); }

using namespace std;

int n,m,k;
int ar[MAXN];

struct q{
	int l,r,d;
};

int tree[4*MAXN];
int lazy[4*MAXN];

q query[100005];
int tree2[4*MAXN];
int lazy2[4*MAXN];
int ar2[MAXN];
void build(int node,int l,int r){

	if(l > r ) return;

	if(l == r){
		tree[node] = ar[l];
		return;
	}

	build(node*2+1,l,(l+r)/2);
	build(node*2+2,(l+r)/2+1,r);

	tree[node] = tree[node*2+1] + tree[node*2+2];

}

void build2(int node,int l,int r){

	if(l > r ) return;

	if(l == r){
		tree2[node] = ar2[l];
		return;
	}

	build2(node*2+1,l,(l+r)/2);
	build2(node*2+2,(l+r)/2+1,r);

	tree2[node] = tree2[node*2+1] + tree2[node*2+2];

}

void update2(int node,int l,int r,int x,int y){
	if(lazy2[node] != 0){
		tree2[node] += lazy2[node];
		if(l != r){
			lazy2[node*2+1] += lazy2[node];
			lazy2[node*2+2] += lazy2[node];
		}
		lazy2[node] = 0;
	}
	if(l > r || l > y || r < x) return;
	if(l >= x && r <= y){
		tree2[node] += 1;
		if(l != r){
			lazy2[node*2+1] += 1;
			lazy2[node*2+2] += 1;
		}
		return;
	}
	update2(node*2+1,l,(l+r)/2,x,y);
	update2(node*2+2,(l+r)/2+1,r,x,y);
	tree2[node] = tree2[node*2+1] + tree2[node*2+2];
}

void update(int node,int l,int r,int x,int y,int value){
	if(lazy[node] != 0){
		tree[node] += lazy[node];
		if(l != r){
			lazy[node*2+1] += lazy[node];
			lazy[node*2+2] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > r || l > y || r < x) return;
	if(l >= x && r <= y){
		tree[node] += value;
		if(l != r){
			lazy[node*2+1] += value;
			lazy[node*2+2] += value;
		}
		return;
	}
	update(node*2+1,l,(l+r)/2,x,y,value);
	update(node*2+2,(l+r)/2+1,r,x,y,value);
	tree[node] = tree[node*2+1] + tree[node*2+2];
}

int query2(int node,int l,int r,int x,int y){

	if(l > r || l > y || r < x) return 0;

	if(lazy2[node] != 0){
		tree2[node] += lazy2[node];
		if(l != r){
			lazy2[node*2+1] = lazy2[node];
			lazy2[node*2+2] = lazy2[node];
		}
		lazy2[node] = 0;
	}
	if(l >= x && r <= y) {
		return tree2[node]	;
	}

	int q1 = query2(node*2+1,l,(l+r)/2,x,y);
	int q2 = query2(node*2+2,(l+r)/2+1,r,x,y);

	int result = q1 + q2;

	return result;
}

int query3(int node,int l,int r,int x,int y){

	if(l > r || l > y || r < x) return 0;

	if(lazy[node] != 0){
		tree[node] += lazy[node];
		if(l != r){
			lazy[node*2+1] = lazy[node];
			lazy[node*2+2] = lazy[node];
		}
		lazy[node] = 0;
	}
	if(l >= x && r <= y) {
		return tree[node]	;
	}

	int q1 = query3(node*2+1,l,(l+r)/2,x,y);
	int q2 = query3(node*2+2,(l+r)/2+1,r,x,y);

	int result = q1 + q2;

	return result;
}

int qq(int node,int l,int r,int x,int y){

	if(l > r || l > y || r < x) return 0;

	if(lazy2[node] != 0){
		tree2[node] += lazy2[node];
		if(l != r){
			lazy2[node*2+1] = lazy2[node];
			lazy2[node*2+2] = lazy2[node];
		}
		lazy2[node] = 0;
	}
	if(l >= x && r <= y) {
		return tree2[node];
	}

	int q1 = qq(node*2+1,l,(l+r)/2,x,y);
	int q2 = qq(node*2+2,(l+r)/2+1,r,x,y);

	int result = q1 + q2;

	return result;
}

int main (){
	memset(lazy,0,sizeof(lazy));
	memset(ar2,0,sizeof(ar2));
	memset(lazy2,0,sizeof(lazy2));
	scanf("%d%d%d",&n,&m,&k);

	for(int i=0;i<n;i++){
		scanf("%d",&ar[i]);
	}
	build(1,0,n-1);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&query[i].l,&query[i].r,&query[i].d);
	}

	for(int i=0;i<k;i++){
		int t1,t2;
		scanf("%d%d",&t1,&t2);
		update2(1,0,n-1,t1-1,t2-1);
	}

	for(int i=1;i<=m;i++){
		int results = qq(1,0,n-1,i-1,i-1);
		int batas_kiri = query[i].l;
		int batas_kanan = query[i].r;
		int tambah = query[i].d;
//		cout << "Batas Kiri : " << batas_kiri << endl;
//		cout << "Batas Kanan: " << batas_kanan << endl;
//		cout << "Tambah     : " << tambah << endl;
//		cout << "Result     : " << results << endl << endl;
		update(1,0,n-1,batas_kiri-1,batas_kanan-1,tambah*results);
	}

	for(int i=0;i<n;i++){
		printf("%d ",query3(1,0,n-1,i,i));
	}

	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <cstdlib>
#include <utility>
#include<iostream>
#include <iterator>
#include <set>
typedef long long ll;
#define fi first
#define se second
#define PB(a) push_back(a);
#define INF = 1000000000;
#define REP(i,n) for (int i = 0; i < n; i++)
#define REPI(i,n) for (int i = 1; i <= n; i++)
#define REPN(i,n) for (int i = n-1; i >= 0; i--)
#define REPF(j,i,n) for (int j = i; j < n; j++)
#define LL long long
#define PI pair<int,int>
#define PL pair<long,long>
#define vi vector<int>
#define MAXN 100005
//int gcd(int a,int b){ return b == 0 ? a : gcd(b,a%b);}
//int lcm(int a,int b){ return a * (b/gcd(a,b)); }

using namespace std;

int n,m,k;
int ar[MAXN];

struct q{
	int l,r,d;
};

LL tree[4*MAXN];
LL lazy[4*MAXN];

q query[100005];
LL tree2[4*MAXN];
LL lazy2[4*MAXN];
LL ar2[MAXN];
void build(int node,int l,int r){

	if(l > r ) return;

	if(l == r){
		tree[node] = ar[l];
		return;
	}

	build(node*2+1,l,(l+r)/2);
	build(node*2+2,(l+r)/2+1,r);

	tree[node] = tree[node*2+1] + tree[node*2+2];

}

void build2(int node,int l,int r){

	if(l > r ) return;

	if(l == r){
		tree2[node] = ar2[l];
		return;
	}

	build2(node*2+1,l,(l+r)/2);
	build2(node*2+2,(l+r)/2+1,r);

	tree2[node] = tree2[node*2+1] + tree2[node*2+2];

}

void update2(int node,int l,int r,int x,int y){
	if(lazy2[node] != 0){
		tree2[node] += lazy2[node]  * (r-l+1);
		if(l != r){
			lazy2[node*2+1] += lazy2[node];
			lazy2[node*2+2] += lazy2[node];
		}
		lazy2[node] = 0;
	}
	if(l > r || l > y || r < x) return;
	if(l >= x && r <= y){
		tree2[node] += 1;
		if(l != r){
			lazy2[node*2+1] += 1;
			lazy2[node*2+2] += 1;
		}
		return;
	}
	update2(node*2+1,l,(l+r)/2,x,y);
	update2(node*2+2,(l+r)/2+1,r,x,y);
	tree2[node] = tree2[node*2+1] + tree2[node*2+2];
}

void update(int node,int l,int r,int x,int y,LL value){
	if(lazy[node] != 0){
		tree[node] += lazy[node]  * (r-l+1);
		if(l != r){
			lazy[node*2+1] += lazy[node];
			lazy[node*2+2] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > r || l > y || r < x) return;
	if(l >= x && r <= y){
		tree[node] += value * (r-l+1);
		if(l != r){
			lazy[node*2+1] += value;
			lazy[node*2+2] += value;
		}
		return;
	}
	update(node*2+1,l,(l+r)/2,x,y,value);
	update(node*2+2,(l+r)/2+1,r,x,y,value);
	tree[node] = tree[node*2+1] + tree[node*2+2];
}

LL query3(int node,int l,int r,int x,int y){

	if(l > r || l > y || r < x) return 0;

	if(lazy[node] != 0){
		tree[node] += lazy[node]  * (r-l+1);
		if(l != r){
			lazy[node*2+1] += lazy[node];
			lazy[node*2+2] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l >= x && r <= y) {
		return tree[node]	;
	}

	LL q1 = query3(node*2+1,l,(l+r)/2,x,y);
	LL q2 = query3(node*2+2,(l+r)/2+1,r,x,y);

	LL result = q1 + q2;

	return result;
}

LL qq(int node,int l,int r,int x,int y){

	if(l > r || l > y || r < x) return 0;

	if(lazy2[node] != 0){
		tree2[node] += lazy2[node]  * (r-l+1);
		if(l != r){
			lazy2[node*2+1] += lazy2[node];
			lazy2[node*2+2] += lazy2[node];
		}
		lazy2[node] = 0;
	}
	if(l >= x && r <= y) {
		return tree2[node];
	}

	LL q1 = qq(node*2+1,l,(l+r)/2,x,y);
	LL q2 = qq(node*2+2,(l+r)/2+1,r,x,y);

	LL result = q1 + q2;

	return result;
}

int main (){
	memset(lazy,0,sizeof(lazy));
	memset(ar2,0,sizeof(ar2));
	memset(lazy2,0,sizeof(lazy2));
	scanf("%d%d%d",&n,&m,&k);

	for(int i=0;i<n;i++){
		scanf("%d",&ar[i]);
	}
	build(0,0,n-1);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&query[i].l,&query[i].r,&query[i].d);
	}

	for(int i=0;i<k;i++){
		int t1,t2;
		scanf("%d%d",&t1,&t2);
		update2(0,0,n-1,t1-1,t2-1);
	}

	for(int i=1;i<=m;i++){
		LL results = qq(0,0,n-1,i-1,i-1);
		LL batas_kiri = query[i].l;
		LL batas_kanan = query[i].r;
		LL tambah = query[i].d;
//		cout << "Batas Kiri : " << batas_kiri << endl;
//		cout << "Batas Kanan: " << batas_kanan << endl;
//		cout << "Tambah     : " << tambah << endl;
//		cout << "Result     : " << results << endl << endl;
		update(0,0,n-1,batas_kiri-1,batas_kanan-1,tambah*results);
	}

	for(int i=0;i<n;i++){
		printf("%I64d ",query3(0,0,n-1,i,i));
	}

	return 0;
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;

#define oo 5+1e9;

int main()
{

    long long queries[100010];
    long long a[100010];
    long long b[100010];
    long long n, m, k;
    long long i;
    long long op[100010][3];
    long long x, y;

    memset(queries, 0, sizeof(queries));
    memset(b, 0, sizeof(b));

    scanf("%d%d%d", &n, &m, &k);
    for(i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for(i = 1; i <= m; ++i)
        scanf("%d %d %d",&op[i][0], &op[i][1], &op[i][2]);

    for(i = 0; i < k; ++i){
        scanf("%d %d", &x, &y);
        queries[x] += 1;
        queries[y+1] -= 1;
    }

    for(i = 1; i <= m; ++i)
        queries[i] += queries[i-1];

    for(i = 1; i <= m; ++i)
        op[i][2] *= queries[i];

    for(i = 1; i <= n; ++i)
        b[i] = a[i] - a[i-1];

    memset(a, 0, sizeof(a));

    for(i = 1; i <= m; ++i){
        a[op[i][0]] += op[i][2];
        a[op[i][1]+1] -= op[i][2];
    }

    for(i = 1; i <= n; ++i)
        b[i] = b[i-1] + a[i] + b[i];

    for(i = 1; i <= n; ++i)
        printf("%I64d ", b[i]);

    return 0;
}


#include <cstdio>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;

int main()
{

    int queries[100010];
    long long a[100010];
    long long b[100010];
    int n, m, k;
    int i;
    long long op[100010][3];
    int x,y;

    memset(queries, 0, sizeof(queries));
    memset(b, 0, sizeof(b));

    scanf("%d%d%d", &n, &m,&k);
    for(i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for(i = 1; i <= m; ++i)
        scanf("%d %d %d",&op[i][0],&op[i][1],&op[i][2]);

    for(i = 0; i < k; ++i){
        scanf("%d %d", &x, &y);
        queries[x]+=1;
        queries[y+1]-=1;
    }

    for(i = 1; i <=m; ++i)
        queries[i]+=queries[i-1];

    for(i = 1; i <=m; ++i)
        op[i][2]*=queries[i];

    for(i = 1; i <=n; ++i)
            b[i]=a[i]-a[i-1];

    memset(a,0,sizeof(a));

    for(i = 1; i <=m; ++i){
        a[op[i][0]]+=op[i][2];
        a[op[i][1]+1]-=op[i][2];
    }

    for(i = 1; i <=n; ++i)
        b[i] = b[i-1] + a[i]+b[i];

    for(i = 1; i <=n; ++i)
        printf("%I64d ", b[i]);

    return 0;
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;
long long queries[100010];
long long a[100010];
long long b[100010];
long long n, m, k;
long long i;
long long op[100010][3];
long long x, y;

int main()
{
ios::sync_with_stdio(0);
cin >> n >> m >> k;
for(i = 1; i <= n; ++i)
cin >> a[i];
for(i = 1; i <= m; ++i)
cin >> op[i][0] >> op[i][1] >> op[i][2];
//scanf("%d %d %d",&op[i][0], &op[i][1], &op[i][2]);

for(i = 0; i < k; ++i){
cin >> x >> y;
//scanf("%d %d", &x, &y);
queries[x] += 1;
queries[y+1] -= 1;
}

for(i = 1; i <= m; ++i)
queries[i] += queries[i-1];

for(i = 1; i <= m; ++i)
op[i][2] *= queries[i];

for(i = 1; i <= n; ++i)
b[i] = a[i] - a[i-1];

for(i = 1; i <= m; ++i){
b[op[i][0]] += op[i][2];
b[op[i][1]+1] -= op[i][2];
}

for(i = 1; i <= n; ++i)
b[i] = b[i-1] + b[i];

for(i = 1; i <= n; ++i)
cout << b[i] << ' ';

return 0;
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;

#define oo 5+1e9;

int main()
{

    long long queries[100010];
    unsigned long long a[100010];
    unsigned long long b[100010];
    unsigned long long n, m, k;
    unsigned long long i;
    unsigned long long op[100010][3];
    unsigned long long x, y;

    memset(queries, 0, sizeof(queries));
    memset(b, 0, sizeof(b));

    scanf("%d%d%d", &n, &m, &k);
    for(i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for(i = 1; i <= m; ++i)
        scanf("%d %d %d",&op[i][0], &op[i][1], &op[i][2]);

    for(i = 0; i < k; ++i){
        scanf("%d %d", &x, &y);
        queries[x] += 1;
        queries[y+1] -= 1;
    }

    for(i = 1; i <= m; ++i)
        queries[i] += queries[i-1];

    for(i = 1; i <= m; ++i)
        op[i][2] *= queries[i];

    for(i = 1; i <= n; ++i)
        b[i] = a[i] - a[i-1];

    memset(a, 0, sizeof(a));

    for(i = 1; i <= m; ++i){
        a[op[i][0]] += op[i][2];
        a[op[i][1]+1] -= op[i][2];
    }

    for(i = 1; i <= n; ++i)
        b[i] = b[i-1] + a[i] + b[i];

    for(i = 1; i <= n; ++i)
        printf("%I64d ", b[i]);

    return 0;
}


#include <cstdio>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;

int main()
{

    unsigned long long queries[100010];
    unsigned long long a[100010];
    unsigned long long b[100010];
    unsigned long long n, m, k;
    unsigned long long i;
    unsigned long long op[100010][3];
    unsigned long long x,y;

    memset(queries, 0, sizeof(queries));
    memset(b, 0, sizeof(b));

    scanf("%d%d%d", &n, &m,&k);
    for(i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for(i = 1; i <= m; ++i)
        scanf("%d %d %d",&op[i][0],&op[i][1],&op[i][2]);

    for(i = 0; i < k; ++i){
        scanf("%d %d", &x, &y);
        queries[x]+=1;
        queries[y+1]-=1;
    }

    for(i = 1; i <=m; ++i)
        queries[i]+=queries[i-1];

    for(i = 1; i <=m; ++i)
        op[i][2]*=queries[i];

    for(i = 1; i <=n; ++i)
            b[i]=a[i]-a[i-1];

    memset(a,0,sizeof(a));

    for(i = 1; i <=m; ++i){
        a[op[i][0]]+=op[i][2];
        a[op[i][1]+1]-=op[i][2];
    }

    for(i = 1; i <=n; ++i)
        b[i] = b[i-1] + a[i]+b[i];

    for(i = 1; i <=n; ++i)
        printf("%I64d ", b[i]);

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=100010;
long long ans[maxn];
long long x[maxn];
int n,m,k;
struct qnode
{
    int ee,val;
    int id;
}qq[maxn];
int cmp(qnode a,qnode b)
{
    return a.ee>b.ee;
}
int main()
{
    int i,j;
    int u,v;
    int l,r;
    int idx=0;
    int val;
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=n;i++)
    {
        cin>>ans[i];
    }
    for (i=1;i<=m;i++)
    {
        scanf("%d%d%d",&l,&r,&val);
        ++idx;
        qq[idx].ee=l-1,qq[idx].id=i,qq[idx].val=-val;
        ++idx;
        qq[idx].ee=r,qq[idx].id=i,qq[idx].val=val;
    }
    sort(qq+1,qq+1+idx,cmp);
    memset(x,0,sizeof(x));
    for (i=1;i<=k;i++)
    {
        scanf("%d%d",&u,&v);
        x[u-1]--;
        x[v]++;
    }
    long long tmp=0;
    for (i=m;i>=1;i--)
    {
        tmp+=x[i];
        x[i]=tmp;
    }
    tmp=0;
    for (i=n,j=1;i>=1;i--)
    {
        for (;j<=idx&&qq[j].ee>=i;j++)
        {
            tmp+=qq[j].val*x[qq[j].id];
        }
        ans[i]+=tmp;
    }
    for (i=1;i<=n;i++)
        cout<<ans[i]<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=100010;
long long ans[maxn];
long long x[maxn];
int n,m,k;
struct qnode
{
    int ee,val;
    int id;
}qq[2*maxn];
int cmp(qnode a,qnode b)
{
    return a.ee>b.ee;
}
int main()
{
    int i,j;
    int u,v;
    int l,r;
    int idx=0;
    int val;
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=n;i++)
    {
        scanf("%I64d",&ans[i]);
    }
    for (i=1;i<=m;i++)
    {
        scanf("%d%d%d",&l,&r,&val);
        ++idx;
        qq[idx].ee=l-1,qq[idx].id=i,qq[idx].val=-val;
        ++idx;
        qq[idx].ee=r,qq[idx].id=i,qq[idx].val=val;
    }
    sort(qq+1,qq+1+idx,cmp);
    for (i=1;i<=k;i++)
    {
        scanf("%d%d",&u,&v);
        x[u-1]--;
        x[v]++;
    }
    long long tmp=0;
    for (i=m-1;i>=1;i--)
    {
        x[i]+=x[i+1];
    }

    for (i=n,j=1;i>=1;i--)
    {
        for (;j<=idx&&qq[j].ee>=i;j++)
        {
            tmp+=qq[j].val*x[qq[j].id];
        }
        ans[i]+=tmp;
    }
    for (i=1;i<=n;i++)
        printf("%I64d\n",ans[i]);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=100010;
long long ans[maxn];
long long x[maxn];
int n,m,k;
struct qnode
{
    int ee,val;
    int id;
}qq[2*maxn];
int cmp(qnode a,qnode b)
{
    return a.ee>b.ee;
}
int main()
{
    int i,j;
    int u,v;
    int l,r;
    int idx=0;
    int val;
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=n;i++)
    {
        scanf("%I64d",&ans[i]);
    }
    for (i=1;i<=m;i++)
    {
        scanf("%d%d%d",&l,&r,&val);
        ++idx;
        qq[idx].ee=l-1,qq[idx].id=i,qq[idx].val=-val;
        ++idx;
        qq[idx].ee=r,qq[idx].id=i,qq[idx].val=val;
    }
    sort(qq+1,qq+1+idx,cmp);
    memset(x,0,sizeof(x));
    for (i=1;i<=k;i++)
    {
        scanf("%d%d",&u,&v);
        x[u-1]--;
        x[v]++;
    }
    long long tmp=0;
    for (i=m;i>=1;i--)
    {
        tmp+=x[i];
        x[i]=tmp;
    }
    tmp=0;
    for (i=n,j=1;i>=1;i--)
    {
        for (;j<=idx&&qq[j].ee>=i;j++)
        {
            tmp+=qq[j].val*x[qq[j].id];
        }
        ans[i]+=tmp;
    }
    for (i=1;i<=n;i++)
        printf("%I64d\n",ans[i]);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=100010;
long long ans[maxn];
long long x[maxn];
int n,m,k;
struct qnode
{
    int ee,val;
    int id;
}qq[2*maxn];
int cmp(qnode a,qnode b)
{
    return a.ee>b.ee;
}
int main()
{
    int i,j;
    int u,v;
    int l,r;
    int idx=0;
    int val;
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=n;i++)
    {
        cin>>ans[i];
    }
    for (i=1;i<=m;i++)
    {
        scanf("%d%d%d",&l,&r,&val);
        ++idx;
        qq[idx].ee=l-1,qq[idx].id=i,qq[idx].val=-val;
        ++idx;
        qq[idx].ee=r,qq[idx].id=i,qq[idx].val=val;
    }
    sort(qq+1,qq+1+idx,cmp);
    memset(x,0,sizeof(x));
    for (i=1;i<=k;i++)
    {
        scanf("%d%d",&u,&v);
        x[u-1]--;
        x[v]++;
    }
    long long tmp=0;
    for (i=m;i>=1;i--)
    {
        tmp+=x[i];
        x[i]=tmp;
    }
    tmp=0;
    for (i=n,j=1;i>=1;i--)
    {
        for (;j<=idx&&qq[j].ee>=i;j++)
        {
            tmp+=qq[j].val*x[qq[j].id];
        }
        ans[i]+=tmp;
    }
    for (i=1;i<=n;i++)
        cout<<ans[i]<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=100010;
int c[maxn];
long long ans[maxn];
long long x[maxn];
int n,m,k;
struct qnode
{
    int ee,val;
    int id;
}qq[maxn];
int cmp(qnode a,qnode b)
{
    return a.ee>b.ee;
}
int main()
{
    int i,j;
    int u,v;
    int l,r;
    int idx=0;
    int val;
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=n;i++)
    {
        scanf("%I64d\n",&ans[i]);
    }
    for (i=1;i<=m;i++)
    {
        scanf("%d%d%d",&l,&r,&val);
        ++idx;
        qq[idx].ee=l-1,qq[idx].id=i,qq[idx].val=-val;
        ++idx;
        qq[idx].ee=r,qq[idx].id=i,qq[idx].val=val;
    }
    sort(qq+1,qq+1+idx,cmp);
    for (i=1;i<=k;i++)
    {
        scanf("%d%d",&u,&v);
        x[u-1]--;
        x[v]++;
    }
    long long tmp=0;
    memset(x,0,sizeof(x));
    for (i=m;i>=1;i--)
    {
        tmp+=x[i];
        x[i]=tmp;
    }
    tmp=0;
    for (i=n,j=1;i>=1;i--)
    {
        for (;j<=idx&&qq[j].ee>=i;j++)
        {
            tmp+=qq[j].val*x[qq[j].id];
        }
        ans[i]+=tmp;
    }
    for (i=1;i<=n;i++)
        printf("%I64d\n",ans[i]);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=100010;
int c[maxn];
long long ans[maxn];
int x[maxn];
int n,m,k;
struct qnode
{
    int ee,val;
    int id;
}qq[maxn];
int cmp(qnode a,qnode b)
{
    return a.ee>b.ee;
}
int main()
{
    int i,j;
    int u,v;
    int l,r;
    int idx=0;
    int val;
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=n;i++)
    {
        scanf("%I64d\n",&ans[i]);
    }
    for (i=1;i<=m;i++)
    {
        scanf("%d%d%d",&l,&r,&val);
        ++idx;
        qq[idx].ee=l-1,qq[idx].id=i,qq[idx].val=-val;
        ++idx;
        qq[idx].ee=r,qq[idx].id=i,qq[idx].val=val;
    }
    sort(qq+1,qq+1+idx,cmp);
    for (i=1;i<=k;i++)
    {
        scanf("%d%d",&u,&v);
        x[u-1]--;
        x[v]++;
    }
    int tmp=0;
    for (i=m;i>=1;i--)
    {
        tmp+=x[i];
        x[i]=tmp;
    }
    tmp=0;
    for (i=n,j=1;i>=1;i--)
    {
        for (;j<=idx&&qq[j].ee>=i;j++)
        {
            tmp+=qq[j].val*x[qq[j].id];
        }
        ans[i]+=tmp;
    }
    for (i=1;i<=n;i++)
        printf("%I64d\n",ans[i]);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
const int maxn=100010;
int n,m,k;
int l[maxn],r[maxn],val[maxn];
int visit[maxn];
__int64 ans[maxn];
int main()
{
	int i,j;
	int u,v;
	scanf("%d%d%d",&n,&m,&k);
	for (i=1;i<=n;i++) scanf("%I64d\n",&ans[i]);
	for (i=1;i<=m;i++)
	{
		scanf("%d%d%d",&l[i],&r[i],&val[i]);
	}
	for (i=1;i<=k;i++)
	{
		scanf("%d%d",&u,&v);
		for (j=u;j<=v;j++)
			visit[j]++;
	}
	for (i=1;i<=m;i++)
	{
		if (visit[i])
		{
			for (j=l[i];j<=r[i];j++)
			{
				ans[j]+=visit[i]*val[i];
			}
		}
	}
	for (i=1;i<=n;i++)
		printf("%I64d ",ans[i]);
	printf("\n");

	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=100010;
int c[maxn];
long long ans[maxn];
int x[maxn];
int n,m,k;
struct qnode
{
    int ee,val;
    int id;
}qq[maxn];
int cmp(qnode a,qnode b)
{
    return a.ee>b.ee;
}
int main()
{
    int i,j;
    int u,v;
    int l,r;
    int idx=0;
    int val;
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=n;i++)
    {
        scanf("%I64d\n",&ans[i]);
    }
    for (i=1;i<=m;i++)
    {
        scanf("%d%d%d",&l,&r,&val);
        ++idx;
        qq[idx].ee=l-1,qq[idx].id=i,qq[idx].val=-val;
        ++idx;
        qq[idx].ee=r,qq[idx].id=i,qq[idx].val=val;
    }
    sort(qq+1,qq+1+idx,cmp);
    for (i=1;i<=k;i++)
    {
        scanf("%d%d",&u,&v);
        x[u-1]--;
        x[v]++;
    }
    long long tmp=0;
    for (i=m;i>=1;i--)
    {
        tmp+=x[i];
        x[i]=tmp;
    }
    tmp=0;
    for (i=n,j=1;i>=1;i--)
    {
        for (;j<=idx&&qq[j].ee>=i;j++)
        {
            tmp+=qq[j].val*x[qq[j].id];
        }
        ans[i]+=tmp;
    }
    for (i=1;i<=n;i++)
        printf("%I64d\n",ans[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll A[100005],O[100005],Q[100005];
pair<pair< int, int>, ll > OP[100005];
int main()
{
	int N,M,K;
	cin >> N >> M >> K;

	for (int i = 0; i < N; ++i)
		cin >> A[i];

	int l,r; ll d;
	for(int i = 0 ; i < M; i++)
	{
		cin >> l >> r >> d;
		OP[i] = make_pair( make_pair(l,r),d);
	}
	int a,b;
	for(int i = 0 ;i < K; i++)
	{
		cin >> a >> b;
		Q[a-1] ++;
		Q[b] --;
	}

	int streak = 0;
	for(int i = 0 ; i < M; i++)
	{
		//cout << Q[i] << " ";
		streak += Q[i];
		if(streak < 0)
			while(1);
		OP[i].second *= streak;
		O[OP[i].first.first - 1] += OP[i].second;
		O[OP[i].first.second] -= OP[i].second;
	}
	//cout << endl;
	streak = 0;
	for(int i = 0; i < N; i++)
	{

		streak += O[i];
		//if(streak < 0)
		//	while(1);
		A[i] += streak;
		cout << A[i] << " ";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int A[100005],O[100005],Q[100005];
pair<pair< int, int>, int > OP[100005];
int main()
{
	int N,M,K;
	cin >> N >> M >> K;

	for (int i = 0; i < N; ++i)
		cin >> A[i];

	int l,r,d;
	for(int i = 0 ; i < M; i++)
	{
		cin >> l >> r >> d;
		OP[i] = make_pair( make_pair(l,r),d);
	}
	int a,b;
	for(int i = 0 ;i < K; i++)
	{
		cin >> a >> b;
		Q[a-1] ++;
		Q[b] --;
	}

	int streak = 0;
	for(int i = 0 ; i < M; i++)
	{
		//cout << Q[i] << " ";
		streak += Q[i];
		OP[i].second *= streak;
		O[OP[i].first.first - 1] += OP[i].second;
		O[OP[i].first.second] -= OP[i].second;
	}
	//cout << endl;
	streak = 0;
	for(int i = 0; i < N; i++)
	{
		streak += O[i];
		A[i] += streak;
		cout << A[i] << " ";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll A[100005],O[100005],Q[100005];
pair<pair< int, int>, ll > OP[100005];
int main()
{
	int N,M,K;
	cin >> N >> M >> K;

	for (int i = 0; i < N; ++i)
		cin >> A[i];

	int l,r; ll d;
	for(int i = 0 ; i < M; i++)
	{
		cin >> l >> r >> d;
		OP[i] = make_pair( make_pair(l,r),d);
	}
	int a,b;
	for(int i = 0 ;i < K; i++)
	{
		cin >> a >> b;
		Q[a-1] ++;
		Q[b] --;
	}

	ll streak = 0;
	for(int i = 0 ; i < M; i++)
	{
		//cout << Q[i] << " ";
		streak += Q[i];
		OP[i].second *= streak;
		O[OP[i].first.first - 1] += OP[i].second;
		O[OP[i].first.second] -= OP[i].second;
	}
	//cout << endl;
	streak = 0;
	for(int i = 0; i < N; i++)
	{

		streak += O[i];
		if(streak < 0)
			while(1);
		A[i] += streak;
		cout << A[i] << " ";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll A[100005],O[100005],Q[100005];
pair<pair< int, int>, ll > OP[100005];
int main()
{
	int N,M,K;
	cin >> N >> M >> K;

	for (int i = 0; i < N; ++i)
		cin >> A[i];

	int l,r; ll d;
	for(int i = 0 ; i < M; i++)
	{
		cin >> l >> r >> d;
		OP[i] = make_pair( make_pair(l,r),d);
	}
	int a,b;
	for(int i = 0 ;i < K; i++)
	{
		cin >> a >> b;
		Q[a-1] ++;
		Q[b] --;
	}

	int streak = 0;
	for(int i = 0 ; i < M; i++)
	{
		//cout << Q[i] << " ";
		streak += Q[i];
		OP[i].second *= streak;
		O[OP[i].first.first - 1] += OP[i].second;
		O[OP[i].first.second] -= OP[i].second;
	}
	//cout << endl;
	streak = 0;
	for(int i = 0; i < N; i++)
	{
		streak += O[i];
		A[i] += streak;
		cout << A[i] << " ";
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long cs,tst;
    cin>>cs;
    for(tst=1;tst<=cs;tst++)
    {
        string s;
        cin>>s;
        long flag1=00,flag2=0,flag3=0,flag4=0,ans=0,t=0;
        for(int i=0;i<2;i++)
        {
            if(s[i]=='X' and s[i]==s[i+2] and s[i]==s[i+4] and s[i]==s[i+6] and s[i]==s[i+8] and s[i]==s[i+10])
            {
                t=1;
                flag1=1;
                ans++;
                break;
            }
        }
        for(int i=0;i<3;i++)
        {
            if(s[i]=='X' and s[i]==s[i+3] and s[i]==s[i+6] and s[i]==s[i+9])
            {
                t=1;
                flag2=1;
                ans++;break;
            }
        }
        for(int i=0;i<4;i++)
        {
            if(s[i]=='X' and s[i]==s[i+4] and s[i]==s[i+8])
            {
                t=1;
                flag3=1;
                ans++;break;
            }
        }
        for(int i=0;i<6;i++)
        {
            if(s[i]=='X' and s[i]==s[i+6])
            {
                t=1;
                flag4=1;
                ans++;break;
            }
        }
        long count=0;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]=='X')
                {
                    t=1;
                    count++;
                }
        }
      //  cout<<ans<<endl;
        if(t==0)
            cout<<0<<endl;
        else
            {
        if(count==12)
            ans++;
        cout<<ans+1<<" ";
        cout<<"1X12 ";
         if(flag4==1)
                cout<<"2X6 ";
                if(flag3==1)
                cout<<"3X4 ";
        if(flag2==1)
            cout<<"4X3 ";
                 if(flag1==1)
            cout<<"6X2"<<" ";
            if(count==12)
                cout<<"12X1";
                cout<<endl;
                ans=0;
            }

    }
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define nl printf("\n")
#define spc printf(" ")
#define sci(n) scanf("%ld",&n)
#define scc(n) scanf("%c",&n)
#define sc64(n) scanf("%I64d",&n)
#define scii(a,b) scanf("%ld %ld",&a,&b)
#define sc6464(a,b) scanf("%I64d %I64d",&a,&b)
#define scs(s) scanf("%s",s)
#define scss(a,b) scanf("%s %s",a,b)
#define scd(f) scanf("%lf",&f)
#define scdd(a,b) scanf("%lf %lf",&a,&b)
#define pfi(a) printf("%ld",a)
#define pfc(a) printf("%c",a)
#define pf64(a) printf("%I64d",a)
#define pfii(a,b) printf("%ld %ld",a,b)
#define pf6464(a,b) printf("%I64d %I64d",a,b)
#define pfs(a) printf("%s",a)
#define pfss(a,b) printf("%s %s",a,b)
#define pfd(a) printf("%lf",a)
#define pfdd(a,b) printf("%lf %lf",a,b)
#define inf 1000000000000LL
#define eps 1e-11
#define open freopen("input.txt","r",stdin)
#define close freopen ("output.txt","w",stdout)
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define rep1(i,n) for(__typeof(n) i=0; i<=(n); i++)
#define rep2(i,n) for(__typeof(n) i=1; i<=(n); i++)
#define rep3(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define repe(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define pi 3.14159265358979323846264338327950
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define sz size()
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define mem(a,b) memset(a,b,sizeof(a))
int dx[] = {-1,0,1,1,1,0,-1,-1} , dy[] = {-1,-1,-1,0,1,1,1,0} ;
int cx[] = {1,1,2,2,-1,-1,-2,-2}, cy[] = {2,-2,1,-1,2,-2,1,-1};
typedef long l;
typedef long long ll;
typedef string st;
typedef double d;
typedef vector<int> vi;
typedef vector<string> vs;
template<class T> int len(const T&c){return (int)c.size();}
long long stoi(string s){long long n=0;rep(i,len(s))n=(n<<3)+(n<<1)+(s[i]-48);return n;}
string itos(long long n){ if(n==0) return "0"; string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
int main()
{
ios_base::sync_with_stdio(false);
long tc;
cin>>tc;
while(tc--)
{
    long fuck111;
string s,s1,s2,s3,s4,s5,s6,s7,s8;long t=0,c=0,r=0,r1=0,r2=0,r3=0,r4=0;
cin>>s;
s1=s.substr(0,6);
s2=s.substr(6,12);
rep(i,6)
{
if(s1[i]==s2[i]&&s2[i]=='X')
{
c=1;r=1;
t++;break;
}
}
s1=s.substr(0,4);
s2=s.substr(4,8);
s3=s.substr(8,12);
rep(i,4)
{
if(s1[i]==s2[i]&&s2[i]==s3[i]&&s3[i]=='X')
{
r1=1;
c=1;t++;break;
}
}
s1=s.substr(0,3);
s2=s.substr(3,6);
s3=s.substr(6,9);
s4=s.substr(9,12);
rep(i,3)
{
if(s1[i]==s2[i]&&s2[i]==s3[i]&&s3[i]==s4[i]&&s4[i]=='X')
{
r2=1;
c=1;t++;break;
}
}
if((s[0]=='X'&&s[0]==s[2]&&s[2]==s[4]&&s[4]==s[6]&&s[6]==s[8]&&s[8]==s[10])||(s[1]=='X'&&s[1]==s[3]&&s[3]==s[5]&&s[5]==s[7]&&s[7]==s[9]&&s[9]==s[11]))
{
r3=1;
c=1;t++;
}
long k=0,k1=0;
rep(i,12)
{
if(s[i]=='X')
{
k++;c=1;
}
else
k1++;
}
if(k>0)
t++;
if(k==12)
{
t++;
r4=1;
}
if(k1==12)
cout<<0<<endl;
else
{
cout<<t;
if(k>0)
cout<<" 1x12";
if(r==1)
cout<<" 2x6";
if(r1==1)
cout<<" 3x4";
if(r2==1)
cout<<" 4x3";
if(r3==1)
cout<<" 6x2";
if(r4==1)
cout<<" 12x1";
cout<<endl;
}
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long cs,tst;
    cin>>cs;
    for(tst=1;tst<=cs;tst++)
    {
        string s;
        cin>>s;
        long flag1=00,flag2=0,flag3=0,flag4=0,ans=0,t=0;
        for(int i=0;i<2;i++)
        {
            if(s[i]=='X' and s[i]==s[i+2] and s[i]==s[i+4] and s[i]==s[i+6] and s[i]==s[i+8] and s[i]==s[i+10])
            {
                t=1;
                flag1=1;
                ans++;
                break;
            }
        }
        for(int i=0;i<3;i++)
        {
            if(s[i]=='X' and s[i]==s[i+3] and s[i]==s[i+6] and s[i]==s[i+9])
            {
                t=1;
                flag2=1;
                ans++;break;
            }
        }
        for(int i=0;i<4;i++)
        {
            if(s[i]=='X' and s[i]==s[i+4] and s[i]==s[i+8])
            {
                t=1;
                flag3=1;
                ans++;break;
            }
        }
        for(int i=0;i<6;i++)
        {
            if(s[i]=='X' and s[i]==s[i+6])
            {
                t=1;
                flag4=1;
                ans++;break;
            }
        }
        long count=0;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]=='X')
                {
                    t=1;
                    count++;
                }
        }
      //  cout<<ans<<endl;
        if(t==0)
            cout<<0<<endl;
        else
            {
        if(count==12)
            ans++;
        cout<<ans+1<<" ";
        cout<<"1x12 ";
         if(flag4==1)
                cout<<"2x6 ";
                if(flag3==1)
                cout<<"3x4 ";
        if(flag2==1)
            cout<<"4x3 ";
                 if(flag1==1)
            cout<<"6x2"<<" ";
            if(count==12)
                cout<<"12x1";
                cout<<endl;
                ans=0;
            }

    }
    return 0;
}


#include <iostream>
#include <sstream>
#include <limits.h>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <vector>
#include <math.h>
#include <set>
#include <string>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <map>
#define SI(x) scanf("%d", &x)
#define vi vector<int>
#define PB push_back
#define PI(x) printf("%d\n", x)
#define rep(i, n) for(int i=0;i<n;i++)
#define repx(i,x,n) for(int i=x;i<n;i++)
#define endl "\n"
typedef long long LL;
typedef long long int LLI;
using namespace std;
struct sort_pred {
    bool operator()(const pair<int, int> &left, const pair<int, int> &right) {
        return left.second < right.second;
    }
};
char t[2] = {'+', '-'};
struct convert {
    void operator()(char& c) { c = toupper((unsigned char)c); }
};
struct convertd {
    void operator()(char& c) { c = tolower((unsigned char)c); }
};
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int b[101][101];
int a[101][101];
int main()
{
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    rep(k, t){
        string s;
        cin >> s;
        size_t pos = s.find("X");
        if (pos == string::npos){
            cout << 0 << endl;
            continue;
        }
        if (s == "XXXXXXXXXXXX"){
            cout << "6 1x12 2x6 3x4 4x3 6x2 12x1" << endl;
            continue;
        }
        int cnt = 1;
        vector<string> v;
        v.push_back("1x12");
        string s1 = s.substr(0, 6);
        string s2 = s.substr(6, 12);
        rep(i, 6){
            if (s1[i] == 'X' && s2[i] == 'X')
            {
                cnt++;
                v.push_back("2x6");
                break;
            }
        }
        s1 = s.substr(0, 4);
        s2 = s.substr(4, 8);
        string s3 = s.substr(8, 12);
        rep(i, 4){
            if (s1[i] == 'X' && s2[i] == 'X' && s3[i] == 'X')
            {
                cnt++;
                v.push_back("3x4");
                break;
            }
        }
        s1 = s.substr(0, 3);
        s2 = s.substr(3, 6);
        s3 = s.substr(6, 9);
        string s4 = s.substr(9, 12);
        rep(i, 3){
            if (s1[i] == 'X' && s2[i] == 'X' && s3[i] == 'X')
            {
                cnt++;
                v.push_back("4x3");
                break;
            }
        }
        s1 = s.substr(0, 2);
        s2 = s.substr(2, 4);
        s3 = s.substr(4, 6);
        s4 = s.substr(6, 8);
        string s5 = s.substr(8, 10);
        string s6 = s.substr(10, 12);
        rep(i, 2){
            if (s1[i] == 'X' && s2[i] == 'X' && s3[i] == 'X' && s4[i] == 'X' && s5[i] == 'X' && s6[i] == 'X')
            {
                cnt++;
                v.push_back("6x2");
                break;
            }
        }
        cnt++;
        v.push_back("12x1");
        cout << cnt << " ";
        rep(i, v.size()){
            cout << v[i] << " ";
        }
        cout << endl;
    }
    return 0;
}


#include <iostream>
#include <sstream>
#include <limits.h>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <vector>
#include <math.h>
#include <set>
#include <string>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <map>
#define SI(x) scanf("%d", &x)
#define vi vector<int>
#define PB push_back
#define PI(x) printf("%d\n", x)
#define rep(i, n) for(int i=0;i<n;i++)
#define repx(i,x,n) for(int i=x;i<n;i++)
#define endl "\n"
typedef long long LL;
typedef long long int LLI;
using namespace std;
struct sort_pred {
    bool operator()(const pair<int, int> &left, const pair<int, int> &right) {
        return left.second < right.second;
    }
};
char t[2] = {'+', '-'};
struct convert {
    void operator()(char& c) { c = toupper((unsigned char)c); }
};
struct convertd {
    void operator()(char& c) { c = tolower((unsigned char)c); }
};
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int b[101][101];
int a[101][101];
int main()
{
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    rep(k, t){
        string s;
        cin >> s;
        size_t pos = s.find("X");
        if (pos == string::npos){
            cout << 0 << endl;
            continue;
        }
        if (s == "XXXXXXXXXXXX"){
            cout << "6 1x12 2x6 3x4 4x3 6x2 12x1" << endl;
            continue;
        }
        int cnt = 1;
        vector<string> v;
        v.push_back("1x12");
        string s1 = s.substr(0, 6);
        string s2 = s.substr(6, 12);
        rep(i, 6){
            if (s1[i] == 'X' && s2[i] == 'X')
            {
                cnt++;
                v.push_back("2x6");
                break;
            }
        }
        s1 = s.substr(0, 4);
        s2 = s.substr(4, 8);
        string s3 = s.substr(8, 12);
        rep(i, 4){
            if (s1[i] == 'X' && s2[i] == 'X' && s3[i] == 'X')
            {
                cnt++;
                v.push_back("3x4");
                break;
            }
        }
        s1 = s.substr(0, 3);
        s2 = s.substr(3, 6);
        s3 = s.substr(6, 9);
        string s4 = s.substr(9, 12);
        rep(i, 3){
            if (s1[i] == 'X' && s2[i] == 'X' && s3[i] == 'X' && s4[i] == 'X')
            {
                cnt++;
                v.push_back("4x3");
                break;
            }
        }
        s1 = s.substr(0, 2);
        s2 = s.substr(2, 4);
        s3 = s.substr(4, 6);
        s4 = s.substr(6, 8);
        string s5 = s.substr(8, 10);
        string s6 = s.substr(10, 12);
        rep(i, 2){
            if (s1[i] == 'X' && s2[i] == 'X' && s3[i] == 'X' && s4[i] == 'X' && s5[i] == 'X' && s6[i] == 'X')
            {
                cnt++;
                v.push_back("6x2");
                break;
            }
        }
        if (s[0] == 'X' && s[1] == 'X' && s[2] == 'X' && s[3] == 'X' && s[4] == 'X' && s[5] == 'X' && s[6] == 'X' && s[7] == 'X' && s[8] == 'X' && s[9] == 'X' && s[10] == 'X' && s[11] == 'X')
        {
            cnt++;
            v.push_back("12x1");
        }
        cout << cnt << " ";
        rep(i, v.size()){
            cout << v[i] << " ";
        }
        cout << endl;
    }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define SI(x) scanf("%d", &x)
#define vi vector<int>
#define PB push_back
#define PI(x) printf("%d\n", x)
#define rep(i, n) for(int i=0;i<n;i++)
#define repx(i,x,n) for(int i=x;i<n;i++)
#define endl "\n"
typedef long long LL;
typedef long long int LLI;
using namespace std;
struct sort_pred {
    bool operator()(const pair<int, int> &left, const pair<int, int> &right) {
        return left.second < right.second;
    }
};
char t[2] = {'+', '-'};
struct convert {
    void operator()(char& c) { c = toupper((unsigned char)c); }
};
struct convertd {
    void operator()(char& c) { c = tolower((unsigned char)c); }
};
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

using namespace std;

int n, m;
char s[1010][1010];
int main()
{
    scanf("%d %d\n", &n, &m);
    set<int> z;
    for (int i = 0; i<n; ++i)
    {
        gets(s[i]);
        int G = -1, S = -1;
        for (int j = 0; j<m; ++j) if (s[i][j] == 'G') G = j; else if (s[i][j] == 'S') S = j;
        if (S<G) { puts("-1"); return 0; }
        z.insert(S - G);
    }
    printf("%d\n", int(z.size()));
    return 0;
}


#include <iostream>
#include <sstream>
#include <limits.h>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <vector>
#include <math.h>
#include <set>
#include <string>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <map>
#define SI(x) scanf("%d", &x)
#define vi vector<int>
#define PB push_back
#define PI(x) printf("%d\n", x)
#define rep(i, n) for(int i=0;i<n;i++)
#define repx(i,x,n) for(int i=x;i<n;i++)
#define endl "\n"
typedef long long LL;
typedef long long int LLI;
using namespace std;
struct sort_pred {
	bool operator()(const pair<int, int> &left, const pair<int, int> &right) {
		return left.second < right.second;
	}
};
char t[2] = {'+', '-'};
struct convert {
	void operator()(char& c) { c = toupper((unsigned char)c); }
};
struct convertd {
	void operator()(char& c) { c = tolower((unsigned char)c); }
};
int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}
int n, m;
char s[1010][1010];
int main()
{
	ios::sync_with_stdio(false);
	scanf("%d %d\n", &n, &m);
	set<int> z;
	for (int i = 0; i<n; ++i)
	{
		gets(s[i]);
		int G = -1, S = -1;
		for (int j = 0; j<m; ++j) if (s[i][j] == 'G') G = j; else if (s[i][j] == 'S') S = j;
		if (S<G) { puts("-1"); return 0; }
		z.insert(S - G);
	}
	printf("%d\n", int(z.size()));
	return 0;
}


#include <iostream>
#include <sstream>
#include <limits.h>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <vector>
#include <math.h>
#include <set>
#include <string>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <map>
#define SI(x) scanf("%d", &x)
#define vi vector<int>
#define PB push_back
#define PI(x) printf("%d\n", x)
#define rep(i, n) for(int i=0;i<n;i++)
#define repx(i,x,n) for(int i=x;i<n;i++)
#define endl "\n"
typedef long long LL;
typedef long long int LLI;
using namespace std;
struct sort_pred {
    bool operator()(const pair<int, int> &left, const pair<int, int> &right) {
        return left.second < right.second;
    }
};
char t[2] = {'+', '-'};
struct convert {
    void operator()(char& c) { c = toupper((unsigned char)c); }
};
struct convertd {
    void operator()(char& c) { c = tolower((unsigned char)c); }
};
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int b[101][101];
int a[101][101];
int main()
{
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    rep(k, t){
        string s;
        cin >> s;
        size_t pos = s.find("X");
        if (pos == string::npos){
            cout << 0 << endl;
            continue;
        }
        if (s == "XXXXXXXXXXXX"){
            cout << "6 1x12 2x6 3x4 4x3 6x2 12x1" << endl;
            continue;
        }
        int cnt = 1;
        vector<string> v;
        v.push_back("1x12");
        string s1 = s.substr(0, 6);
        string s2 = s.substr(6, 12);
        rep(i, 6){
            if (s1[i] == 'X' && s2[i] == 'X')
            {
                cnt++;
                v.push_back("2x6");
                break;
            }
        }
        s1 = s.substr(0, 4);
        s2 = s.substr(4, 8);
        string s3 = s.substr(8, 12);
        rep(i, 4){
            if (s1[i] == 'X' && s2[i] == 'X' && s3[i] == 'X')
            {
                cnt++;
                v.push_back("3x4");
                break;
            }
        }
        s1 = s.substr(0, 3);
        s2 = s.substr(3, 6);
        s3 = s.substr(6, 9);
        string s4 = s.substr(9, 12);
        rep(i, 3){
            if (s1[i] == 'X' && s2[i] == 'X' && s3[i] == 'X')
            {
                cnt++;
                v.push_back("4x3");
                break;
            }
        }
        s1 = s.substr(0, 2);
        s2 = s.substr(2, 4);
        s3 = s.substr(4, 6);
        s4 = s.substr(6, 8);
        string s5 = s.substr(8, 10);
        string s6 = s.substr(10, 12);
        rep(i, 2){
            if (s1[i] == 'X' && s2[i] == 'X' && s3[i] == 'X' && s4[i] == 'X' && s5[i] == 'X' && s6[i] == 'X')
            {
                cnt++;
                v.push_back("6x2");
                break;
            }
        }
        if (s[0] == 'X' && s[1] == 'X' && s[2] == 'X' && s[3] == 'X' && s[4] == 'X' && s[5] == 'X' && s[6] == 'X' && s[7] == 'X' && s[8] == 'X' && s[9] == 'X' && s[10] == 'X' && s[11] == 'X')
        {
            cnt++;
            v.push_back("12x1");
        }
        cout << cnt << " ";
        rep(i, v.size()){
            cout << v[i] << " ";
        }
        cout << endl;
    }
    return 0;
}


#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 111, inf = 111111111;

int n;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    set <int> ans;
    for (int i = 0; i < n; ++i) {
        ans.clear();
        string s, q[22];
        cin >> s;
        for (int j = 1; j <= 12; ++j) {
            if (12 % j == 0) {
                for (int k = 0; k < 12 / j; ++k) {
                    for (int z = k * j; z < (k + 1) * j; ++z) {
                        q[k][z - k * j] = s[z];
                    }
                }
                for (int k = 0; k < j; ++k) {
                    int f = 0;
                    for (int z = 0; z < 12 / j; ++z) {
                        if (q[z][k] == 'O') {
                            f = 1;
                            break;
                        }
                    }
                    if (f == 0) {
                        ans.insert(j);
                        break;
                    }
                }
            }
        }
        cout << ans.size();
        if (ans.size() != 0) {
            cout << ' ';
        }
        while (ans.size() != 0) {
            int x = *ans.rbegin();
            ans.erase(x);
            cout << 12 / x << 'x' << x;
            if (ans.size() != 0) {
                cout << ' ';
            }
        }
        cout << endl;
    }
    return 0;
}


#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 111, inf = 111111111;

int n;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    set <int> ans;
    for (int i = 0; i < n; ++i) {
        ans.clear();
        string s, q[22];
        cin >> s;
        for (int j = 1; j <= 12; ++j) {
            if (12 % j == 0) {
                for (int k = 0; k < 12 / j; ++k) {
                    for (int z = k * j; z < (k + 1) * j; ++z) {
                        q[k][z - k * j] = s[z];
                    }
                }
                for (int k = 0; k < j; ++k) {
                    int f = 0;
                    for (int z = 0; z < 12 / j; ++z) {
                        if (q[z][k] == 'O') {
                            f = 1;
                            break;
                        }
                    }
                    if (f == 0) {
                        ans.insert(j);
                        break;
                    }
                }
            }
        }
        cout << ans.size() << ' ';
        while (ans.size() != 0) {
            int x = *ans.rbegin();
            ans.erase(x);
            cout << 12 / x << 'x' << x << ' ';
        }
        cout << endl;
    }
    return 0;
}


#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 111, inf = 111111111;

int n;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    set <int> ans;
    for (int i = 0; i < n; ++i) {
        ans.clear();
        string s, q[22];
        cin >> s;
        for (int j = 1; j <= 12; ++j) {
            if (12 % j == 0) {
                for (int k = 0; k < 12 / j; ++k) {
                    q[k] = "";
                    for (int z = k * j; z < (k + 1) * j; ++z) {
                        q[k] += s[z];
                    }
                }
                for (int k = 0; k < j; ++k) {
                    int f = 0;
                    for (int z = 0; z < 12 / j; ++z) {
                        if (q[z][k] == 'O') {
                            f = 1;
                            break;
                        }
                    }
                    if (f == 0) {
                        ans.insert(j);
                        break;
                    }
                }
            }
        }
        cout << ans.size();
        if (ans.size() != 0) {
            cout << ' ';
        }
        while (ans.size() != 0) {
            int x = *ans.rbegin();
            ans.erase(x);
            cout << 12 / x << 'x' << x;
            if (ans.size() != 0) {
                cout << ' ';
            }
        }
        cout << endl;
    }
    return 0;
}


#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 111, inf = 111111111;

int n;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    set <int> ans;
    for (int i = 0; i < n; ++i) {
        ans.clear();
        string s, q[22];
        cin >> s;
        for (int j = 1; j <= 12; ++j) {
            if (12 % j == 0) {
                for (int k = 0; k < 12 / j; ++k) {
                    for (int z = k * j; z < (k + 1) * j; ++z) {
                        q[k] += s[z];
                    }
                }
                for (int k = 0; k < j; ++k) {
                    int f = 0;
                    for (int z = 0; z < 12 / j; ++z) {
                        if (q[z][k] == 'O') {
                            f = 1;
                            break;
                        }
                    }
                    if (f == 0) {
                        ans.insert(j);
                        break;
                    }
                }
            }
        }
        cout << ans.size();
        if (ans.size() != 0) {
            cout << ' ';
        }
        while (ans.size() != 0) {
            int x = *ans.rbegin();
            ans.erase(x);
            cout << 12 / x << 'x' << x;
            if (ans.size() != 0) {
                cout << ' ';
            }
        }
        cout << endl;
    }
    return 0;
}


#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 111, inf = 111111111;

int n;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    set <int> ans;
    for (int i = 0; i < n; ++i) {
        ans.clear();
        string s, q[22];
        cin >> s;
        for (int j = 1; j <= 12; ++j) {
            if (12 % j == 0) {
                for (int k = 0; k < 12 / j; ++k) {
                    for (int z = k * j; z < (k + 1) * j; ++z) {
                        q[k][z - k * j] = s[z];
                    }
                }
                for (int k = 0; k < j; ++k) {
                    int f = 0;
                    for (int z = 0; z < 12 / j; ++z) {
                        if (q[z][k] == 'O') {
                            f = 1;
                            break;
                        }
                    }
                    if (f == 0) {
                        ans.insert(j);
                        break;
                    }
                }
            }
        }
        cout << ans.size() << ' ';
        while (ans.size() != 0) {
            int x = *ans.rbegin();
            ans.erase(x);
            cout << 12 / x << 'x' << x;
            if (ans.size() != 0) {
                cout << ' ';
            }
        }
        cout << endl;
    }
    return 0;
}


#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 111, inf = 111111111;

int n;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    set <int> ans;
    for (int i = 0; i < n; ++i) {
        ans.clear();
        string s, q[22];
        cin >> s;
        for (int j = 1; j <= 12; ++j) {
            if (12 % j == 0) {
                for (int k = 0; k < 12 / j; ++k) {
                    for (int z = k * j; z < (k + 1) * j; ++z) {
                        q[k][z - k * j] = s[z];
                    }
                }
                for (int k = 0; k < j; ++k) {
                    int f = 0;
                    for (int z = 0; z < 12 / j; ++z) {
                        if (q[z][k] == 'O') {
                            f = 1;
                            break;
                        }
                    }
                    if (f == 0) {
                        ans.insert(j);
                        break;
                    }
                }
            }
        }
        cout << ans.size() << ' ';
        while (ans.size() != 0) {
            int x = *ans.begin();
            ans.erase(x);
            cout << 12 / x << 'x' << x << ' ';
        }
        cout << endl;
    }
    return 0;
}


/****************************************************
***   Problem       :
***   Author        : Kaidul Islam
***   E-mail        : ikaidul@yahoo.com
***   University    : KUET, Dept. of CSE
***   Team          : KUET_BitMask
***   Blog          : http://kaidul.efireit.com
****************************************************/
#include <bits/stdc++.h>

using namespace std;

#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define stream istringstream
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define repl(i,n) for(__typeof(n) i=1; i<=(n); i++)
#define FOR(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define forstl(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define INF (1<<30)
#define PI acos(-1.0)
#define pb push_back
#define ppb pop_back
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define memsp(x) mem(x,MEMSET_INF)
#define memdp(x) mem(x,-1)
#define memca(x) mem(x,0)
#define eps 1e-9
#define pii pair<int,int>
#define pmp make_pair
#define ft first
#define sd second
#define vi vector<int>
#define vpii vector<pii>
#define si set<int>
#define msi map<string , int >
#define mis map<int , string >
typedef long long i64;
typedef unsigned long long ui64;
/** function **/
#define SDi(x) sf("%d", &x)
#define SDl(x) sf("%lld", &x)
#define SDs(x) sf("%s", x)
#define SD2(x,y) sf("%d%d", &x, &y)
#define SD3(x,y,z) sf("%d%d%d", &x, &y, &z)
#define pf printf
#define print(x) pf("%d ", x)
#define println(x) pf("%d\n", x)
#define sf scanf
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const i64 INF64 = (i64)1E18;

template<class T> inline T gcd(T a,T b) {
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<class T> inline T lcm(T a,T b) {
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a, -b);
    return a*(b/gcd(a,b));
}
template<class T> inline T sqr(T x) {
    return x*x;
}
template<class T> T power(T N,T P) {
    return (P==0)?  1: N*power(N,P-1);
}
template<class T> bool inside(T a,T b,T c) {
    return (b>=a && b<=c);
}
double _dist(double x1,double y1,double x2,double y2) {
    return sqrt(sqr(x1-x2)+sqr(y1-
                               y2));
}
int distsq(int x1,int y1,int x2,int y2) {
    return sqr(x1-x2)+sqr(y1-y2);
}
i64 toInt64(string s) {
    i64 r=0;
    istringstream sin(s);
    sin>>r;
    return r;
}
double Log(i64 N, i64 B) {
    return (log10l(N)) / (log10l(B));
}
string itoa(long long a) {
    if(a==0) return "0";
    string ret;
    for(long long i=a; i>0; i=i/10)
        ret.push_back((i%10)+48);
    reverse(ret.begin(),ret.end());
    return ret;
}
vector< string > token( string a, string b ) {
    const char *q = a.c_str();
    while( count( b.begin(), b.end(), *q ) ) q++;
    vector< string > oot;
    while( *q ) {
        const char *e = q;
        while( *e && !count( b.begin(), b.end(), *e ) )
            e++;
        oot.push_back( string( q, e ) );
        q = e;
        while( count( b.begin(), b.end(), *q ) )
            q++;
    }
    return oot;
}

int isvowel(char s) {
    s=tolower(s);
    if(s=='a' or s=='e' or s=='i' or s=='o' or s=='u')
        return 1;
    return 0;
}
int isupper(char s) {
    if(s>='A' and s<='Z') return 1;
    return 0;
}
template<class T> struct Fraction {
    T a,b;
    Fraction(T a=0,T b=1);
    string
    toString();
};//NOTES:Fraction
template<class T> Fraction<T>::Fraction(T a,T b) {
    T d=gcd(a,b);
    a/=d;
    b/=d;
    if (b<0) a=-a, b=-b;
    this->a=a;
    this->b=b;
}
template<class T> string Fraction<T>::toString() {
    ostringstream
    sout;
    sout<<a<<"/"<<b;
    return sout.str();
}
template<class T> Fraction<T> operator+(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b+q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator-(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b-q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator*(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.a,p.b*q.b);
}
template<class T> Fraction<T> operator/(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b,p.b*q.a);
}

/** BitMask **/
int Set(int N, int pos) {
    return N = N | (1 << pos);
}
int Reset(int N,int pos) {
    return N = N & ~(1 << pos);
}
int Check(int N, int pos) {
    return (N & (1 << pos));
}
int toggle(int N, int pos) {
    if( Check(N, pos) )
        return N = Reset(N, pos);
    return N = Set(N, pos);
}

const i64 INFFF = 1e16;

int main(void) {
    int tcase, caseNo = 0;
#ifndef ONLINE_JUDGE
    READ("input.txt");
#endif
    int factorX[] = {1, 2, 3, 4, 6, 12};
    int factorY[] = {12, 6, 4, 3, 2, 1};
    cin >> tcase;
    string input;
    cin >> input;
    vector <int> result;
    for(int i = 0; i < 6; ++i) {
        int x = factorX[i];
        int y = factorY[i];
        bool yes;
        rep(j, y) {
            yes = true;
            int backup = j;
            rep(k, x) {
                if(input[j] != 'X') {
                    yes = false;
                    break;
                }
                j += y;
            }
            j = backup;
        }
        if(yes == true) {
            result.pb(i);
        }
    }
    int n= result.size();
    cout << n << " ";
    rep(i, n) cout << factorX[ result[i] ] << "x" << factorY[ result[i] ] << " ";
    cout << endl;
    return 0;
}


/****************************************************
***   Problem       :
***   Author        : Kaidul Islam
***   E-mail        : ikaidul@yahoo.com
***   University    : KUET, Dept. of CSE
***   Team          : KUET_BitMask
***   Blog          : http://kaidul.efireit.com
****************************************************/
#include <bits/stdc++.h>

using namespace std;

#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define stream istringstream
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define repl(i,n) for(__typeof(n) i=1; i<=(n); i++)
#define FOR(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define forstl(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define INF (1<<30)
#define PI acos(-1.0)
#define pb push_back
#define ppb pop_back
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define memsp(x) mem(x,MEMSET_INF)
#define memdp(x) mem(x,-1)
#define memca(x) mem(x,0)
#define eps 1e-9
#define pii pair<int,int>
#define pmp make_pair
#define ft first
#define sd second
#define vi vector<int>
#define vpii vector<pii>
#define si set<int>
#define msi map<string , int >
#define mis map<int , string >
typedef long long i64;
typedef unsigned long long ui64;
/** function **/
#define SDi(x) sf("%d", &x)
#define SDl(x) sf("%lld", &x)
#define SDs(x) sf("%s", x)
#define SD2(x,y) sf("%d%d", &x, &y)
#define SD3(x,y,z) sf("%d%d%d", &x, &y, &z)
#define pf printf
#define print(x) pf("%d ", x)
#define println(x) pf("%d\n", x)
#define sf scanf
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const i64 INF64 = (i64)1E18;

template<class T> inline T gcd(T a,T b) {
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<class T> inline T lcm(T a,T b) {
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a, -b);
    return a*(b/gcd(a,b));
}
template<class T> inline T sqr(T x) {
    return x*x;
}
template<class T> T power(T N,T P) {
    return (P==0)?  1: N*power(N,P-1);
}
template<class T> bool inside(T a,T b,T c) {
    return (b>=a && b<=c);
}
double _dist(double x1,double y1,double x2,double y2) {
    return sqrt(sqr(x1-x2)+sqr(y1-
                               y2));
}
int distsq(int x1,int y1,int x2,int y2) {
    return sqr(x1-x2)+sqr(y1-y2);
}
i64 toInt64(string s) {
    i64 r=0;
    istringstream sin(s);
    sin>>r;
    return r;
}
double Log(i64 N, i64 B) {
    return (log10l(N)) / (log10l(B));
}
string itoa(long long a) {
    if(a==0) return "0";
    string ret;
    for(long long i=a; i>0; i=i/10)
        ret.push_back((i%10)+48);
    reverse(ret.begin(),ret.end());
    return ret;
}
vector< string > token( string a, string b ) {
    const char *q = a.c_str();
    while( count( b.begin(), b.end(), *q ) ) q++;
    vector< string > oot;
    while( *q ) {
        const char *e = q;
        while( *e && !count( b.begin(), b.end(), *e ) )
            e++;
        oot.push_back( string( q, e ) );
        q = e;
        while( count( b.begin(), b.end(), *q ) )
            q++;
    }
    return oot;
}

int isvowel(char s) {
    s=tolower(s);
    if(s=='a' or s=='e' or s=='i' or s=='o' or s=='u')
        return 1;
    return 0;
}
int isupper(char s) {
    if(s>='A' and s<='Z') return 1;
    return 0;
}
template<class T> struct Fraction {
    T a,b;
    Fraction(T a=0,T b=1);
    string
    toString();
};//NOTES:Fraction
template<class T> Fraction<T>::Fraction(T a,T b) {
    T d=gcd(a,b);
    a/=d;
    b/=d;
    if (b<0) a=-a, b=-b;
    this->a=a;
    this->b=b;
}
template<class T> string Fraction<T>::toString() {
    ostringstream
    sout;
    sout<<a<<"/"<<b;
    return sout.str();
}
template<class T> Fraction<T> operator+(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b+q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator-(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b-q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator*(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.a,p.b*q.b);
}
template<class T> Fraction<T> operator/(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b,p.b*q.a);
}

/** BitMask **/
int Set(int N, int pos) {
    return N = N | (1 << pos);
}
int Reset(int N,int pos) {
    return N = N & ~(1 << pos);
}
int Check(int N, int pos) {
    return (N & (1 << pos));
}
int toggle(int N, int pos) {
    if( Check(N, pos) )
        return N = Reset(N, pos);
    return N = Set(N, pos);
}

const i64 INFFF = 1e16;

int main(void) {
    int tcase, caseNo = 0;
#ifndef ONLINE_JUDGE
    READ("input.txt");
#endif
    int factorX[] = {1, 2, 3, 4, 6, 12};
    int factorY[] = {12, 6, 4, 3, 2, 1};
    cin >> tcase;
    string input;
    while(cin >> input) {
        vector <int> result;
        for(int i = 0; i < 6; ++i) {
            int x = factorX[i];
            int y = factorY[i];
            bool yes;
            rep(j, y) {
                yes = true;
                int backup = j;
                rep(k, x) {
                    if(input[j] != 'X') {
                        yes = false;
                        break;
                    }
                    j += y;
                }
                j = backup;
            }
            if(yes == true) {
                result.pb(i);
            }
        }
        int n= result.size();
        cout << n << " ";
        rep(i, n) {
            cout << factorX[ result[i] ] << "x" << factorY[ result[i] ];
            if(i < n - 1) cout << " ";
        }
        cout << endl;
    }

    return 0;
}


/****************************************************
***   Problem       :
***   Author        : Kaidul Islam
***   E-mail        : ikaidul@yahoo.com
***   University    : KUET, Dept. of CSE
***   Team          : KUET_BitMask
***   Blog          : http://kaidul.efireit.com
****************************************************/
#include <bits/stdc++.h>

using namespace std;

#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define stream istringstream
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define repl(i,n) for(__typeof(n) i=1; i<=(n); i++)
#define FOR(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define forstl(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define INF (1<<30)
#define PI acos(-1.0)
#define pb push_back
#define ppb pop_back
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define memsp(x) mem(x,MEMSET_INF)
#define memdp(x) mem(x,-1)
#define memca(x) mem(x,0)
#define eps 1e-9
#define pii pair<int,int>
#define pmp make_pair
#define ft first
#define sd second
#define vi vector<int>
#define vpii vector<pii>
#define si set<int>
#define msi map<string , int >
#define mis map<int , string >
typedef long long i64;
typedef unsigned long long ui64;
/** function **/
#define SDi(x) sf("%d", &x)
#define SDl(x) sf("%lld", &x)
#define SDs(x) sf("%s", x)
#define SD2(x,y) sf("%d%d", &x, &y)
#define SD3(x,y,z) sf("%d%d%d", &x, &y, &z)
#define pf printf
#define print(x) pf("%d ", x)
#define println(x) pf("%d\n", x)
#define sf scanf
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const i64 INF64 = (i64)1E18;

template<class T> inline T gcd(T a,T b) {
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<class T> inline T lcm(T a,T b) {
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a, -b);
    return a*(b/gcd(a,b));
}
template<class T> inline T sqr(T x) {
    return x*x;
}
template<class T> T power(T N,T P) {
    return (P==0)?  1: N*power(N,P-1);
}
template<class T> bool inside(T a,T b,T c) {
    return (b>=a && b<=c);
}
double _dist(double x1,double y1,double x2,double y2) {
    return sqrt(sqr(x1-x2)+sqr(y1-
                               y2));
}
int distsq(int x1,int y1,int x2,int y2) {
    return sqr(x1-x2)+sqr(y1-y2);
}
i64 toInt64(string s) {
    i64 r=0;
    istringstream sin(s);
    sin>>r;
    return r;
}
double Log(i64 N, i64 B) {
    return (log10l(N)) / (log10l(B));
}
string itoa(long long a) {
    if(a==0) return "0";
    string ret;
    for(long long i=a; i>0; i=i/10)
        ret.push_back((i%10)+48);
    reverse(ret.begin(),ret.end());
    return ret;
}
vector< string > token( string a, string b ) {
    const char *q = a.c_str();
    while( count( b.begin(), b.end(), *q ) ) q++;
    vector< string > oot;
    while( *q ) {
        const char *e = q;
        while( *e && !count( b.begin(), b.end(), *e ) )
            e++;
        oot.push_back( string( q, e ) );
        q = e;
        while( count( b.begin(), b.end(), *q ) )
            q++;
    }
    return oot;
}

int isvowel(char s) {
    s=tolower(s);
    if(s=='a' or s=='e' or s=='i' or s=='o' or s=='u')
        return 1;
    return 0;
}
int isupper(char s) {
    if(s>='A' and s<='Z') return 1;
    return 0;
}
template<class T> struct Fraction {
    T a,b;
    Fraction(T a=0,T b=1);
    string
    toString();
};//NOTES:Fraction
template<class T> Fraction<T>::Fraction(T a,T b) {
    T d=gcd(a,b);
    a/=d;
    b/=d;
    if (b<0) a=-a, b=-b;
    this->a=a;
    this->b=b;
}
template<class T> string Fraction<T>::toString() {
    ostringstream
    sout;
    sout<<a<<"/"<<b;
    return sout.str();
}
template<class T> Fraction<T> operator+(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b+q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator-(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b-q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator*(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.a,p.b*q.b);
}
template<class T> Fraction<T> operator/(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b,p.b*q.a);
}

/** BitMask **/
int Set(int N, int pos) {
    return N = N | (1 << pos);
}
int Reset(int N,int pos) {
    return N = N & ~(1 << pos);
}
int Check(int N, int pos) {
    return (N & (1 << pos));
}
int toggle(int N, int pos) {
    if( Check(N, pos) )
        return N = Reset(N, pos);
    return N = Set(N, pos);
}

const i64 INFFF = 1e16;

int main(void) {
    int tcase, caseNo = 0;
#ifndef ONLINE_JUDGE
    READ("input.txt");
#endif
    int factorX[] = {1, 2, 3, 4, 6, 12};
    int factorY[] = {12, 6, 4, 3, 2, 1};
    cin >> tcase;
    string input;
    vector <int> result;
    while(tcase--) {
        cin >> input;
        result.clear();
        for(int i = 0; i < 6; ++i) {
            int x = factorX[i];
            int y = factorY[i];
            bool yes;
            rep(j, y) {
                yes = true;
                int backup = j;
                rep(k, x) {
                    if(input[j] != 'X') {
                        yes = false;
                        break;
                    }
                    j += y;
                }
                if(yes == true) break;
                j = backup;
            }
            if(yes == true) {
                result.pb(i);
            }
        }
        int n= result.size();
        cout << n << " ";
        rep(i, n) {
            cout << factorX[ result[i] ] << "x" << factorY[ result[i] ];
            if(i < n - 1) cout << " ";
        }
        cout << endl;
    }

    return 0;
}


/****************************************************
***   Problem       :
***   Author        : Kaidul Islam
***   E-mail        : ikaidul@yahoo.com
***   University    : KUET, Dept. of CSE
***   Team          : KUET_BitMask
***   Blog          : http://kaidul.efireit.com
****************************************************/
#include <bits/stdc++.h>

using namespace std;

#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define stream istringstream
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define repl(i,n) for(__typeof(n) i=1; i<=(n); i++)
#define FOR(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define forstl(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define INF (1<<30)
#define PI acos(-1.0)
#define pb push_back
#define ppb pop_back
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define memsp(x) mem(x,MEMSET_INF)
#define memdp(x) mem(x,-1)
#define memca(x) mem(x,0)
#define eps 1e-9
#define pii pair<int,int>
#define pmp make_pair
#define ft first
#define sd second
#define vi vector<int>
#define vpii vector<pii>
#define si set<int>
#define msi map<string , int >
#define mis map<int , string >
typedef long long i64;
typedef unsigned long long ui64;
/** function **/
#define SDi(x) sf("%d", &x)
#define SDl(x) sf("%lld", &x)
#define SDs(x) sf("%s", x)
#define SD2(x,y) sf("%d%d", &x, &y)
#define SD3(x,y,z) sf("%d%d%d", &x, &y, &z)
#define pf printf
#define print(x) pf("%d ", x)
#define println(x) pf("%d\n", x)
#define sf scanf
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const i64 INF64 = (i64)1E18;

template<class T> inline T gcd(T a,T b) {
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<class T> inline T lcm(T a,T b) {
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a, -b);
    return a*(b/gcd(a,b));
}
template<class T> inline T sqr(T x) {
    return x*x;
}
template<class T> T power(T N,T P) {
    return (P==0)?  1: N*power(N,P-1);
}
template<class T> bool inside(T a,T b,T c) {
    return (b>=a && b<=c);
}
double _dist(double x1,double y1,double x2,double y2) {
    return sqrt(sqr(x1-x2)+sqr(y1-
                               y2));
}
int distsq(int x1,int y1,int x2,int y2) {
    return sqr(x1-x2)+sqr(y1-y2);
}
i64 toInt64(string s) {
    i64 r=0;
    istringstream sin(s);
    sin>>r;
    return r;
}
double Log(i64 N, i64 B) {
    return (log10l(N)) / (log10l(B));
}
string itoa(long long a) {
    if(a==0) return "0";
    string ret;
    for(long long i=a; i>0; i=i/10)
        ret.push_back((i%10)+48);
    reverse(ret.begin(),ret.end());
    return ret;
}
vector< string > token( string a, string b ) {
    const char *q = a.c_str();
    while( count( b.begin(), b.end(), *q ) ) q++;
    vector< string > oot;
    while( *q ) {
        const char *e = q;
        while( *e && !count( b.begin(), b.end(), *e ) )
            e++;
        oot.push_back( string( q, e ) );
        q = e;
        while( count( b.begin(), b.end(), *q ) )
            q++;
    }
    return oot;
}

int isvowel(char s) {
    s=tolower(s);
    if(s=='a' or s=='e' or s=='i' or s=='o' or s=='u')
        return 1;
    return 0;
}
int isupper(char s) {
    if(s>='A' and s<='Z') return 1;
    return 0;
}
template<class T> struct Fraction {
    T a,b;
    Fraction(T a=0,T b=1);
    string
    toString();
};//NOTES:Fraction
template<class T> Fraction<T>::Fraction(T a,T b) {
    T d=gcd(a,b);
    a/=d;
    b/=d;
    if (b<0) a=-a, b=-b;
    this->a=a;
    this->b=b;
}
template<class T> string Fraction<T>::toString() {
    ostringstream
    sout;
    sout<<a<<"/"<<b;
    return sout.str();
}
template<class T> Fraction<T> operator+(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b+q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator-(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b-q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator*(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.a,p.b*q.b);
}
template<class T> Fraction<T> operator/(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b,p.b*q.a);
}

/** BitMask **/
int Set(int N, int pos) {
    return N = N | (1 << pos);
}
int Reset(int N,int pos) {
    return N = N & ~(1 << pos);
}
int Check(int N, int pos) {
    return (N & (1 << pos));
}
int toggle(int N, int pos) {
    if( Check(N, pos) )
        return N = Reset(N, pos);
    return N = Set(N, pos);
}

const i64 INFFF = 1e16;

int main(void) {
    int tcase, caseNo = 0;
#ifndef ONLINE_JUDGE
    READ("input.txt");
#endif
    int factorX[] = {1, 2, 3, 4, 6, 12};
    int factorY[] = {12, 6, 4, 3, 2, 1};
    cin >> tcase;
    string input;
    while(tcase--) {
            cin >> input;
        vector <int> result;
        for(int i = 0; i < 6; ++i) {
            int x = factorX[i];
            int y = factorY[i];
            bool yes;
            rep(j, y) {
                yes = true;
                int backup = j;
                rep(k, x) {
                    if(input[j] != 'X') {
                        yes = false;
                        break;
                    }
                    j += y;
                }
                j = backup;
            }
            if(yes == true) {
                result.pb(i);
            }
        }
        int n= result.size();
        cout << n << " ";
        rep(i, n) {
            cout << factorX[ result[i] ] << "x" << factorY[ result[i] ];
            if(i < n - 1) cout << " ";
        }
        cout << endl;
    }

    return 0;
}


/****************************************************
***   Problem       :
***   Author        : Kaidul Islam
***   E-mail        : ikaidul@yahoo.com
***   University    : KUET, Dept. of CSE
***   Team          : KUET_BitMask
***   Blog          : http://kaidul.efireit.com
****************************************************/
#include <bits/stdc++.h>

using namespace std;

#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define stream istringstream
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define repl(i,n) for(__typeof(n) i=1; i<=(n); i++)
#define FOR(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define forstl(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define INF (1<<30)
#define PI acos(-1.0)
#define pb push_back
#define ppb pop_back
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define memsp(x) mem(x,MEMSET_INF)
#define memdp(x) mem(x,-1)
#define memca(x) mem(x,0)
#define eps 1e-9
#define pii pair<int,int>
#define pmp make_pair
#define ft first
#define sd second
#define vi vector<int>
#define vpii vector<pii>
#define si set<int>
#define msi map<string , int >
#define mis map<int , string >
typedef long long i64;
typedef unsigned long long ui64;
/** function **/
#define SDi(x) sf("%d", &x)
#define SDl(x) sf("%lld", &x)
#define SDs(x) sf("%s", x)
#define SD2(x,y) sf("%d%d", &x, &y)
#define SD3(x,y,z) sf("%d%d%d", &x, &y, &z)
#define pf printf
#define print(x) pf("%d ", x)
#define println(x) pf("%d\n", x)
#define sf scanf
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const i64 INF64 = (i64)1E18;

template<class T> inline T gcd(T a,T b) {
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<class T> inline T lcm(T a,T b) {
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a, -b);
    return a*(b/gcd(a,b));
}
template<class T> inline T sqr(T x) {
    return x*x;
}
template<class T> T power(T N,T P) {
    return (P==0)?  1: N*power(N,P-1);
}
template<class T> bool inside(T a,T b,T c) {
    return (b>=a && b<=c);
}
double _dist(double x1,double y1,double x2,double y2) {
    return sqrt(sqr(x1-x2)+sqr(y1-
                               y2));
}
int distsq(int x1,int y1,int x2,int y2) {
    return sqr(x1-x2)+sqr(y1-y2);
}
i64 toInt64(string s) {
    i64 r=0;
    istringstream sin(s);
    sin>>r;
    return r;
}
double Log(i64 N, i64 B) {
    return (log10l(N)) / (log10l(B));
}
string itoa(long long a) {
    if(a==0) return "0";
    string ret;
    for(long long i=a; i>0; i=i/10)
        ret.push_back((i%10)+48);
    reverse(ret.begin(),ret.end());
    return ret;
}
vector< string > token( string a, string b ) {
    const char *q = a.c_str();
    while( count( b.begin(), b.end(), *q ) ) q++;
    vector< string > oot;
    while( *q ) {
        const char *e = q;
        while( *e && !count( b.begin(), b.end(), *e ) )
            e++;
        oot.push_back( string( q, e ) );
        q = e;
        while( count( b.begin(), b.end(), *q ) )
            q++;
    }
    return oot;
}

int isvowel(char s) {
    s=tolower(s);
    if(s=='a' or s=='e' or s=='i' or s=='o' or s=='u')
        return 1;
    return 0;
}
int isupper(char s) {
    if(s>='A' and s<='Z') return 1;
    return 0;
}
template<class T> struct Fraction {
    T a,b;
    Fraction(T a=0,T b=1);
    string
    toString();
};//NOTES:Fraction
template<class T> Fraction<T>::Fraction(T a,T b) {
    T d=gcd(a,b);
    a/=d;
    b/=d;
    if (b<0) a=-a, b=-b;
    this->a=a;
    this->b=b;
}
template<class T> string Fraction<T>::toString() {
    ostringstream
    sout;
    sout<<a<<"/"<<b;
    return sout.str();
}
template<class T> Fraction<T> operator+(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b+q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator-(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b-q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator*(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.a,p.b*q.b);
}
template<class T> Fraction<T> operator/(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b,p.b*q.a);
}

/** BitMask **/
int Set(int N, int pos) {
    return N = N | (1 << pos);
}
int Reset(int N,int pos) {
    return N = N & ~(1 << pos);
}
int Check(int N, int pos) {
    return (N & (1 << pos));
}
int toggle(int N, int pos) {
    if( Check(N, pos) )
        return N = Reset(N, pos);
    return N = Set(N, pos);
}

const i64 INFFF = 1e16;

int main(void) {
    int tcase, caseNo = 0;
#ifndef ONLINE_JUDGE
    READ("input.txt");
#endif
    int factorX[] = {1, 2, 3, 4, 6, 12};
    int factorY[] = {12, 6, 4, 3, 2, 1};
    cin >> tcase;
    string input;
    while(cin >> input) {
        vector <int> result;
        for(int i = 0; i < 6; ++i) {
            int x = factorX[i];
            int y = factorY[i];
            bool yes;
            rep(j, y) {
                yes = true;
                int backup = j;
                rep(k, x) {
                    if(input[j] != 'X') {
                        yes = false;
                        break;
                    }
                    j += y;
                }
                j = backup;
            }
            if(yes == true) {
                result.pb(i);
            }
        }
        int n= result.size();
        cout << n << " ";
        rep(i, n) cout << factorX[ result[i] ] << "x" << factorY[ result[i] ] << " ";
        cout << endl;
    }

    return 0;
}


/****************************************************
***   Problem       :
***   Author        : Kaidul Islam
***   E-mail        : ikaidul@yahoo.com
***   University    : KUET, Dept. of CSE
***   Team          : KUET_BitMask
***   Blog          : http://kaidul.efireit.com
****************************************************/
#include <bits/stdc++.h>

using namespace std;

#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define stream istringstream
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define repl(i,n) for(__typeof(n) i=1; i<=(n); i++)
#define FOR(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define forstl(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define INF (1<<30)
#define PI acos(-1.0)
#define pb push_back
#define ppb pop_back
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define memsp(x) mem(x,MEMSET_INF)
#define memdp(x) mem(x,-1)
#define memca(x) mem(x,0)
#define eps 1e-9
#define pii pair<int,int>
#define pmp make_pair
#define ft first
#define sd second
#define vi vector<int>
#define vpii vector<pii>
#define si set<int>
#define msi map<string , int >
#define mis map<int , string >
typedef long long i64;
typedef unsigned long long ui64;
/** function **/
#define SDi(x) sf("%d", &x)
#define SDl(x) sf("%lld", &x)
#define SDs(x) sf("%s", x)
#define SD2(x,y) sf("%d%d", &x, &y)
#define SD3(x,y,z) sf("%d%d%d", &x, &y, &z)
#define pf printf
#define print(x) pf("%d ", x)
#define println(x) pf("%d\n", x)
#define sf scanf
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const i64 INF64 = (i64)1E18;

template<class T> inline T gcd(T a,T b) {
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<class T> inline T lcm(T a,T b) {
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a, -b);
    return a*(b/gcd(a,b));
}
template<class T> inline T sqr(T x) {
    return x*x;
}
template<class T> T power(T N,T P) {
    return (P==0)?  1: N*power(N,P-1);
}
template<class T> bool inside(T a,T b,T c) {
    return (b>=a && b<=c);
}
double _dist(double x1,double y1,double x2,double y2) {
    return sqrt(sqr(x1-x2)+sqr(y1-
                               y2));
}
int distsq(int x1,int y1,int x2,int y2) {
    return sqr(x1-x2)+sqr(y1-y2);
}
i64 toInt64(string s) {
    i64 r=0;
    istringstream sin(s);
    sin>>r;
    return r;
}
double Log(i64 N, i64 B) {
    return (log10l(N)) / (log10l(B));
}
string itoa(long long a) {
    if(a==0) return "0";
    string ret;
    for(long long i=a; i>0; i=i/10)
        ret.push_back((i%10)+48);
    reverse(ret.begin(),ret.end());
    return ret;
}
vector< string > token( string a, string b ) {
    const char *q = a.c_str();
    while( count( b.begin(), b.end(), *q ) ) q++;
    vector< string > oot;
    while( *q ) {
        const char *e = q;
        while( *e && !count( b.begin(), b.end(), *e ) )
            e++;
        oot.push_back( string( q, e ) );
        q = e;
        while( count( b.begin(), b.end(), *q ) )
            q++;
    }
    return oot;
}

int isvowel(char s) {
    s=tolower(s);
    if(s=='a' or s=='e' or s=='i' or s=='o' or s=='u')
        return 1;
    return 0;
}
int isupper(char s) {
    if(s>='A' and s<='Z') return 1;
    return 0;
}
template<class T> struct Fraction {
    T a,b;
    Fraction(T a=0,T b=1);
    string
    toString();
};//NOTES:Fraction
template<class T> Fraction<T>::Fraction(T a,T b) {
    T d=gcd(a,b);
    a/=d;
    b/=d;
    if (b<0) a=-a, b=-b;
    this->a=a;
    this->b=b;
}
template<class T> string Fraction<T>::toString() {
    ostringstream
    sout;
    sout<<a<<"/"<<b;
    return sout.str();
}
template<class T> Fraction<T> operator+(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b+q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator-(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b-q.a*p.b,p.b*q.b);
}
template<class T> Fraction<T> operator*(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.a,p.b*q.b);
}
template<class T> Fraction<T> operator/(Fraction<T> p,Fraction<T> q) {
    return
        Fraction<T>(p.a*q.b,p.b*q.a);
}

/** BitMask **/
int Set(int N, int pos) {
    return N = N | (1 << pos);
}
int Reset(int N,int pos) {
    return N = N & ~(1 << pos);
}
int Check(int N, int pos) {
    return (N & (1 << pos));
}
int toggle(int N, int pos) {
    if( Check(N, pos) )
        return N = Reset(N, pos);
    return N = Set(N, pos);
}

const i64 INFFF = 1e16;

int main(void) {
    int tcase, caseNo = 0;
#ifndef ONLINE_JUDGE
    READ("input.txt");
#endif
    int factorX[] = {1, 2, 3, 4, 6, 12};
    int factorY[] = {12, 6, 4, 3, 2, 1};
    cin >> tcase;
    string input;
    cin >> input;
    vector <int> result;
    for(int i = 0; i < 6; ++i) {
        int x = factorX[i];
        int y = factorY[i];
        bool yes;
        rep(j, y) {
            yes = true;
            int backup = j;
            rep(k, x) {
                if(input[j] != 'X') {
                    yes = false;
                    break;
                }
                j += y;
            }
            j = backup;
        }
        if(yes == true) {
            result.pb(i);
        }
    }
    int n= result.size();
    cout << n << " ";
    rep(i, n) cout << factorX[ result[i] ] << "*" << factorY[ result[i] ] << " ";
    cout << endl;
    return 0;
}


#pragma comment(linker,"/STACK:16777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <iterator>
#include <cmath>
#include <algorithm>

using namespace std;
typedef long long lint;
const int INF = (1<<29);
#define NN 100010
#define upto 1001

#define CLR( a ) memset( a , 0 , sizeof ( a ) )
#define negCLR( a ) memset( a , -1 , sizeof( a ) )
#define isComposite( a, n ) ( a[ n >> 6 ] & ( 1 << ((n >> 1)&31 ) ) )
#define mark( a, n ) ( a[ n >> 6 ] |= ( 1 << (( n >> 1)&31 ) ) )

char arr[ 14 ];
char crr[ 14 ];
bool mark[ 14 ];
int brr[ 7 ] = { 1, 2, 3, 4, 6, 12 };

int f( int ith, int j ) {
    //cout<<" "<<ith<<" "<<endl;
    if( ith > 12 ) return 1;
    if( arr[ ith ] == 'X' ) f(  ith + j, j );
    else {
        return 0;
    }
}

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("myout.txt","w",stdout);
    int cases, caseno = 0;
    scanf("%d",&cases);
    while( cases-- ) {  ++caseno;
      scanf("%s",&crr);
      CLR( arr );
      int fl = 0, xl = 0;
      for( int i = 0; i < 12; i++) {
        arr[ i + 1 ] = crr[ i ] ;
        if( crr[ i ] != 'X'){ fl = 1; }
        else { xl = 1; }
      }
      int cnt = 0;
      CLR(mark);
      if( xl ) {
        mark[ 1 ] = 1;
      }
      if( !fl && xl ) {
        printf("6 1x12 2x6 3x4 4x3 6x2 12x1");
      } else {
          for( int i = 1; i <= 6; i++ ) {
            //cout<<" going with "<<i<<endl;
            for( int j = 1; j<= 4; j++ ) {
                //cout<<" with "<<brr[ j ]<<endl;
              if( f( i, brr[ j ] ) ) {
                mark[ brr[ j ] ] = 1;
              }
            }
          }
          for( int i = 0; i<= 5; i++){ if(mark[brr[ i ]])cnt++; }

          if( caseno == 64 || caseno == 65 )cout<<endl<<crr<<endl;
          printf("%d",cnt);
          if( mark[ 1 ] ){ printf(" 1x12");}
          for( int i = 4; i >= 1; i--) {
            if( mark[ brr[ i ] ] ) {
                printf(" %dx%d", 12/brr[ i ],brr[ i ] );
            }
          }
      }

      printf("\n");

    }
    return 0;
}
//OOOOOXOOOOOX
//OOOOOXOOOOOO


#pragma comment(linker,"/STACK:16777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <iterator>
#include <cmath>
#include <algorithm>

using namespace std;
typedef long long lint;
const int INF = (1<<29);
#define NN 100010
#define upto 1001

#define CLR( a ) memset( a , 0 , sizeof ( a ) )
#define negCLR( a ) memset( a , -1 , sizeof( a ) )
#define isComposite( a, n ) ( a[ n >> 6 ] & ( 1 << ((n >> 1)&31 ) ) )
#define mark( a, n ) ( a[ n >> 6 ] |= ( 1 << (( n >> 1)&31 ) ) )

char arr[ 14 ];
char crr[ 14 ];
bool mark[ 14 ];
int brr[ 7 ] = { 1, 2, 3, 4, 6, 12 };

int f( int ith, int j ) {
    //cout<<" "<<ith<<" "<<endl;
    if( ith > 12 ) return 1;
    if( arr[ ith ] == 'X' ) f(  ith + j, j );
    else {
        return 0;
    }
}

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("myout.txt","w",stdout);
    int cases, caseno = 0;
    scanf("%d",&cases);
    while( cases-- ) {
      scanf("%s",&crr);
      CLR( arr );
      int fl = 0, xl = 0;
      for( int i = 0; i < 12; i++) {
        arr[ i + 1 ] = crr[ i ] ;
        if( crr[ i ] != 'X'){ fl = 1; }
        else { xl = 1; }
      }
      int cnt = 0;
      CLR(mark);
      if( xl ) {
        mark[ 1 ] = 1;
      }
      if( !fl && xl ) {
        printf("6 1x12 2x6 3x4 4x3 6x2 12x1");
      } else {
          for( int i = 1; i <= 6; i++ ) {
            //cout<<" going with "<<i<<endl;
            for( int j = 1; j<= 4; j++ ) {
                //cout<<" with "<<brr[ j ]<<endl;
              if( f( i, brr[ j ] ) ) {
                mark[ brr[ j ] ] = 1;
              }
            }
          }
          for( int i = 0; i<= 5; i++){ if(mark[brr[ i ]])cnt++; }
          if( cnt == 2 )cout<<endl<<crr<<endl;
          printf("%d",cnt);
          if( mark[ 1 ] ){ printf(" 1x12");}
          for( int i = 4; i >= 1; i--) {
            if( mark[ brr[ i ] ] ) {
                printf(" %dx%d", 12/brr[ i ],brr[ i ] );
            }
          }
      }

      printf("\n");

    }
    return 0;
}
//OOOOOXOOOOOX
//OOOOOXOOOOOO


#pragma comment(linker,"/STACK:16777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <iterator>
#include <cmath>
#include <algorithm>

using namespace std;
typedef long long lint;
const int INF = (1<<29);
#define NN 100010
#define upto 1001

#define CLR( a ) memset( a , 0 , sizeof ( a ) )
#define negCLR( a ) memset( a , -1 , sizeof( a ) )
#define isComposite( a, n ) ( a[ n >> 6 ] & ( 1 << ((n >> 1)&31 ) ) )
#define mark( a, n ) ( a[ n >> 6 ] |= ( 1 << (( n >> 1)&31 ) ) )

char arr[ 14 ];
char crr[ 14 ];
bool mark[ 14 ];
int brr[ 7 ] = { 1, 2, 3, 4, 6, 12 };

int f( int ith, int j ) {
    //cout<<" "<<ith<<" "<<endl;
    if( ith > 12 ) return 1;
    if( arr[ ith ] == 'X' ) f(  ith + j, j );
    else {
        return 0;
    }
}

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("myout.txt","w",stdout);
    int cases, caseno = 0;
    scanf("%d",&cases);
    while( cases-- ) {
      scanf("%s",&crr);
      CLR( arr );
      int fl = 0, xl = 0;
      for( int i = 0; i < 12; i++) {
        arr[ i + 1 ] = crr[ i ] ;
        if( crr[ i ] != 'X'){ fl = 1; }
        else { xl = 1; }
      }
      int cnt = 0;
      CLR(mark);
      if( xl ) {
        mark[ 1 ] = 1;
      }
      if( !fl && xl ) {
        printf("6 1x12 2x6 3x4 4x3 6x2 12x1");
      } else {
          for( int i = 1; i <= 6; i++ ) {
            //cout<<" going with "<<i<<endl;
            for( int j = 1; j<= 4; j++ ) {
                //cout<<" with "<<brr[ j ]<<endl;
              if( f( i, brr[ j ] ) ) {
                mark[ brr[ j ] ] = 1;
              }
            }
          }
          for( int i = 0; i<= 5; i++){ if(mark[brr[ i ]])cnt++; }
          printf("%d",cnt);
          if( mark[ 1 ] ){ printf(" 1x12");}
          for( int i = 4; i >= 1; i--) {
            if( mark[ brr[ i ] ] ) {
                printf(" %dx%d", 12/brr[ i ],brr[ i ] );
            }
          }
      }

      //if( cnt == 2 )cout<<endl<<crr<<endl;
      printf("\n");

    }
    return 0;
}
//OOOOOXOOOOOX


#pragma comment(linker,"/STACK:16777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <iterator>
#include <cmath>
#include <algorithm>

using namespace std;
typedef long long lint;
const int INF = (1<<29);
#define NN 100010
#define upto 1001

#define CLR( a ) memset( a , 0 , sizeof ( a ) )
#define negCLR( a ) memset( a , -1 , sizeof( a ) )
#define isComposite( a, n ) ( a[ n >> 6 ] & ( 1 << ((n >> 1)&31 ) ) )
#define mark( a, n ) ( a[ n >> 6 ] |= ( 1 << (( n >> 1)&31 ) ) )

char arr[ 14 ];
char crr[ 14 ];
bool mark[ 14 ];
int brr[ 7 ] = { 1, 2, 3, 4, 6, 12 };

int f( int ith ) {
    //printf("---%d\n",ith);
    if( ith >= 11 ) return 1;
    if( arr[ ith ] == 'X' ) f( ith + ith );
    else {
        return 0;
    }
}

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("myout.txt","w",stdout);
    int cases, caseno = 0;
    scanf("%d",&cases);
    while( cases-- ) {
      scanf("%s",&crr);
      CLR( arr );
      int fl = 0, xl = 0;
      for( int i = 0; i < 12; i++) {
        arr[ i + 1 ] = crr[ i ] ;
        if( crr[ i ] != 'X'){ fl = 1; }
        else { xl = 1; }
      }
      int cnt = 0;
      CLR(mark);
      if( xl ) {
        cnt = 1;
        mark[ 1 ] = 1;
      }
      if( !fl && xl ) {
        printf("6 1x12 2x6 3x4 4x3 6x2 12x1");
      } else {

          for( int i = 1; i <= 4; i++ ) {
            if(!mark[ brr[ i ] ] ) {
                //cout<<" going with "<<brr[ i ]<<endl;
                if( f( brr[ i ] ) ) {
                    cnt++;
                    mark[ brr[ i ] ] = 1;
                    if( brr[ i ] == 2 ) { mark[ 4 ] = mark[ 6 ] = 1; }
                    if( brr[ i ] == 3 ) { mark[ 6 ] = 1; }
                }
            } else {
                cnt++;
            }
          }

          printf("%d",cnt); if( mark[ 1 ] ){ printf(" 1x12");}
          for( int i = 5; i >= 1; i--) {
            if( mark[ brr[ i ] ] ) {
                printf(" %dx%d", 12/brr[ i ],brr[ i ] );
            }
          }
      }

      printf("\n");

    }
    return 0;
}


#pragma comment(linker,"/STACK:16777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <iterator>
#include <cmath>
#include <algorithm>

using namespace std;
typedef long long lint;
const int INF = (1<<29);
#define NN 100010
#define upto 1001

#define CLR( a ) memset( a , 0 , sizeof ( a ) )
#define negCLR( a ) memset( a , -1 , sizeof( a ) )
#define isComposite( a, n ) ( a[ n >> 6 ] & ( 1 << ((n >> 1)&31 ) ) )
#define mark( a, n ) ( a[ n >> 6 ] |= ( 1 << (( n >> 1)&31 ) ) )

char arr[ 14 ];
char crr[ 14 ];
bool mark[ 14 ];
int brr[ 7 ] = { 1, 2, 3, 4, 6, 12 };

int f( int ith, int j ) {
    //cout<<" "<<ith<<" "<<endl;
    if( ith > 12 ) return 1;
    if( arr[ ith ] == 'X' ) f(  ith + j, j );
    else {
        return 0;
    }
}

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("myout.txt","w",stdout);
    int cases, caseno = 0;
    scanf("%d",&cases);
    while( cases-- ) {  ++caseno;
      scanf("%s",&crr);
      CLR( arr );
      int fl = 0, xl = 0;
      for( int i = 0; i < 12; i++) {
        arr[ i + 1 ] = crr[ i ] ;
        if( crr[ i ] != 'X'){ fl = 1; }
        else { xl = 1; }
      }
      int cnt = 0;
      CLR(mark);
      if( xl ) {
        mark[ 1 ] = 1;
      }
      if( !fl && xl ) {
        printf("6 1x12 2x6 3x4 4x3 6x2 12x1");
      } else {
          for( int i = 1; i <= 6; i++ ) {
            //cout<<" going with "<<i<<endl;
            for( int j = 1; j<= 4; j++ ) {
                //cout<<" with "<<brr[ j ]<<endl;
              if( f( i, brr[ j ] ) ) {
                mark[ brr[ j ] ] = 1;
              }
            }
          }
          for( int i = 0; i<= 5; i++){ if(mark[brr[ i ]])cnt++; }

          if( caseno == 68 )cout<<crr<<endl;
          printf("%d",cnt);
          if( mark[ 1 ] ){ printf(" 1x12");}
          for( int i = 4; i >= 1; i--) {
            if( mark[ brr[ i ] ] ) {
                printf(" %dx%d", 12/brr[ i ],brr[ i ] );
            }
          }
      }

      printf("\n");

    }
    return 0;
}
//OOOOOXOOOOOX
//OOOOOXOOOOOX
/*
OOOOOXOOOOOO
OOOOOOOXXOXX
OOOOOOOXXXOO
OOOOOOOXXXOX
OOOOOOOXXXXO
OOOOOOOXXXXX
OOOOOOXOOOOO
OOOOOOXOOOOX
OOOOOOXOOOXO
OOOOOOXOOOXX
OOOOOOXOOXOO
OOOOOXOOOOOO
OOOOOXOOOOOX
*/