import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class re {

	public static void main (String[] args) throws IOException
	{
	    //
		BufferedReader	reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
		int n = Integer.parseInt(reader.readLine());

		String res = "";
		for(int i = 0; i<n;i++)
		{
			String data = reader.readLine();
			int xs = countChar(data, 'X');
			int os = countChar(data,'O');

			if(os==12)
			{
				res = "0";
				writer.println(res);
				continue;
			}
			if(xs == 12)
			{
				res = "6 1x12 2x6 3x4 4x3 6x2 12x1";
				writer.println(res);

			}
			else
			{
				int count = 1;

				res = "1x12";

				int a = 2;
				int b = 6;
				while(true)
				{
					boolean isWinner = true;

				    for(int y = 0; y < b ; y++)
					{
				    	isWinner = true;
						for(int x = y;x < data.length();x+= b)
						{
							char card = data.charAt(x);
							if(card == 'O')
							{
								isWinner = false;
								break;
							}
						}
						if(isWinner)
							break;
					}
				    if(isWinner)
				    {
				    	res =res + " " + a+"x"+b;
				    	count++;
				    }
				    int[] vals = nextOne(a, b);
				    a = vals[0];
				    b = vals[1];
				    if(a==-1)
				    	break;

				}
				res = count +" "+ res;
				writer.println(res);
			}

		}
		reader.close();
		writer.close();
	}

	private static int countChar (String data,char c)
	{
		int count = 0;
		for(int i = 0; i<data.length();i++)
		{
			if(data.charAt(i) == c)
				count ++;
		}
		return count;
	}
	private static int[] nextOne(int a,int b)
	{
		int[] vals = new int[2];
		 switch(a)
		    {
		    	case 2:
		    		a = 3;
		    		b = 4;
		    		break;
		    	case 3:
		    		a = 4;
		    		b = 3;
		    		break;
		    	case 4:
		    		a = 6;
		    		b = 2;
		    		break;
		    	case 6:
		    		a = 12;
		    		b = 1;
		    		break;
		    	case 12:
		    		a = -1;
		    		b = -1;
		    		break;

		    }
		 vals[0] = a;
		 vals[1] = b;
		 return vals;
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class re {

	public static void main (String[] args) throws IOException
	{
		BufferedReader	reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
		int n = Integer.parseInt(reader.readLine());

		String res = "";
		for(int i = 0; i<n;i++)
		{
			String data = reader.readLine();
			int xs = countChar(data, 'X');
			int os = countChar(data,'O');

			if(os==12)
			{
				res = "0";
				writer.println(res);
				continue;
			}
			if(xs == 12)
			{
				res = "6 1x12 2x6 3x4 4x3 6x2 12x1";
				writer.println(res);

			}
			else
			{
				int count = 1;

				res = "1x12";

				int a = 2;
				int b = 6;
				while(true)
				{
					boolean isWinner = true;

				    for(int y = 0; y < b ; y++)
					{
				    	isWinner = true;
						for(int x = y;x < data.length();x+= b)
						{
							char card = data.charAt(x);
							if(card == 'O')
							{
								isWinner = false;
								break;
							}
						}
						if(isWinner)
							break;
					}
				    if(isWinner)
				    {
				    	res =res + " " + a+"x"+b;
				    	count++;
				    }
				    int[] vals = nextOne(a, b);
				    a = vals[0];
				    b = vals[1];
				    if(a==-1)
				    	break;

				}
				res = count +" "+ res;
				writer.println(res);
			}

		}
		reader.close();
		writer.close();
	}

	private static int countChar (String data,char c)
	{
		int count = 0;
		for(int i = 0; i<data.length();i++)
		{
			if(data.charAt(i) == c)
				count ++;
		}
		return count;
	}
	private static int[] nextOne(int a,int b)
	{
		int[] vals = new int[2];
		 switch(a)
		    {
		    	case 2:
		    		a = 3;
		    		b = 4;
		    		break;
		    	case 3:
		    		a = 4;
		    		b = 3;
		    		break;
		    	case 4:
		    		a = 6;
		    		b = 2;
		    		break;
		    	case 6:
		    		a = 12;
		    		b = 1;
		    		break;
		    	case 12:
		    		a = -1;
		    		b = -1;
		    		break;

		    }
		 vals[0] = a;
		 vals[1] = b;
		 return vals;
	}

}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static boolean check(String string , int row , int col) {

		char[][] array = new char[20][20];
		int i , j , next = 0;
		for (i = 0;i < row;i ++) {
			for (j = 0;j < col;j ++) {
				array[i][j] = string.charAt(next);
				next ++;
			}
		}
		for (j = 0;j < col;j ++) {
			int cnt = 0;
			for (i = 0;i < row;i ++) {
				if (array[i][j] == 'X') {
					cnt ++;
				}
			}
			if (cnt == row) {
				return true;
			}
		}
		return false;

	}

	public static void main(String[] args) throws Exception {

		Scanner scan = new Scanner(System.in);

		int i , n = scan.nextInt();
		for (i = 0;i < n;i ++) {
			String string = scan.next();
			List<String> ans = new ArrayList<>();
			for (int row = 1;row <= string.length();row ++) {
				if (string.length() % row == 0) {
					int col = string.length() / row;
					if (check(string , row , col)) {
						ans.add(String.format("%dx%d" , row , col));
					}
				}
			}
			System.out.print(ans.size());
			if (ans.size() > 0) {
				for (String s : ans) {
					System.out.print(" " + s);
				}
			}
			System.out.println();
		}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class InnaandChooseOptions {
	public static void main(String[] args) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = new StringTokenizer(br.readLine());
	int n = Integer.parseInt(st.nextToken());

	String s="";

  outer :for(int i=0;i<n;i++) {
		String q = br.readLine();

		int occ=0;
	  if(q.contains("X")) {
		  occ++;
	  s+="1x12 ";
	  }else {
		  System.out.println(0);
	  continue outer;
	  }
	  boolean f=false;
	 int a;
	 int b=6;
	outer2: for(a=2;a<13;a++) {
		if(12%a!=0)
			continue outer2;
			else {
		b=12/a;
		//System.out.println("a"+a+" "+b);

		inner:  for(int j=0;j<b;j++) {
	  for(int z=0;z<a;z++) {

			//System.out.print(q.charAt((12/a)*(z)+j));
     // System.out.println("z:"+z+" j"+j);

				if (q.charAt((12/a)*(z)+j)!='X'){
					continue inner;
				}
			}
		occ++;
			//System.out.println(" ");
			s+=a+"x"+b+" ";
			continue outer2;
		}
	}

	 }System.out.println(occ+" "+s);
  }

}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class InnaandChooseOptions {
	public static void main(String[] args) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = new StringTokenizer(br.readLine());
	int n = Integer.parseInt(st.nextToken());

  outer :for(int i=0;i<n;i++) {
		String q = br.readLine();
		String s="";
		int occ=0;
	  if(q.contains("X")) {
		  occ++;
	  s+="1x12 ";
	  }else {
		  System.out.println(0);
	  continue outer;
	  }
	  boolean f=false;
	 int a;
	 int b=6;
	outer2: for(a=2;a<13;a++) {
		if(12%a!=0)
			continue outer2;
			else {
		b=12/a;
		//System.out.println("a"+a+" "+b);

		inner:  for(int j=0;j<b;j++) {
	  for(int z=0;z<a;z++) {

			//System.out.print(q.charAt((12/a)*(z)+j));
     // System.out.println("z:"+z+" j"+j);

				if (q.charAt((12/a)*(z)+j)!='X'){
					continue inner;
				}
			}
		occ++;
			//System.out.println(" ");
			s+=a+"x"+b+" ";
			continue outer2;
		}
	}

	 }
	 System.out.println(occ+" "+s);
  }

}
}


import java.util.*;
import java.io.*;
import java.lang.*;

public class A400 {

  public static void main(String[] args) {

    int[] set = {1, 2, 3, 4, 6, 12};
    int[] oset = {12, 6,4,3,2,1};
    Boolean[] match = new Boolean[6];
    int n;

    Scanner s = new Scanner(System.in);
    n = s.nextInt();
    for(int i=0; i<n; i++){
      String str = s.next();
      int cnt = 0;
      for(int j=0; j<6; j++){
        match[j]=false;
        for(int k=0; k<oset[j] && !match[j]; k++){
          match[j] = true;
          for(int l=0; l<set[j]; l++){
            match[j] = match[j] && str.charAt(k+oset[j]*l) == 'X';
          }
        }
        if(match[j]) cnt++;
      }
      System.out.print(cnt);
      for(int j=0; j<6; j++)
        if(match[j]) System.out.print(" "+set[j]+"x"+(12/set[j]));
      System.out.println();
    }
  }
}


import java.util.*;
import java.io.*;
import java.lang.*;

public class A400 {

  public static void main(String[] args) {

    int[] set = {1, 2, 3, 4, 6, 12};
    Boolean[] match = new Boolean[6];
    int n;

    Scanner s = new Scanner(System.in);
    n = s.nextInt();
    for(int i=0; i<n; i++){
      String str = s.next();
      int cnt = 0;
      for(int j=0; j<6; j++){
        match[j]=false;
        for(int k=0; k<12/set[j] && !match[j]; k++){
          match[j] = true;
          for(int l=0; k+set[j]*l<12; l++){
            match[j] = match[j] && str.charAt(k+set[j]*l) == 'X';
          }
        }
        if(match[j]) cnt++;
      }
      System.out.print(cnt);
      for(int j=0; j<6; j++)
        if(match[j]) System.out.print(" "+set[j]+"x"+(12/set[j]));
      System.out.println();
    }
  }
}


import java.util.*;
public class tgrb{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int t=Integer.parseInt(sc.nextLine());
        String[]s=new String[t];int c=0;
        for(int i=0;i<t;i++)
            s[i]=sc.nextLine();
        String r="";boolean f=true;
        for(int i=0;i<t;i++){
            for(int j=0;j<12;j++)
                if(s[i].charAt(j)=='X'){
                    r+="1x12 ";c++;break;
                }
            for(int j=0;j<6;j++)
                if(s[i].charAt(j)=='X' && s[i].charAt(j+6)=='X'){
                    r+="2x6 ";c++;break;
                }
            for(int j=0;j<4;j++)
                if(s[i].charAt(j)=='X' && s[i].charAt(j+4)=='X' && s[i].charAt(j+8)=='X'){
                    r+="3x4 ";c++;break;
                }
            for(int j=0;j<3;j++)
                if(s[i].charAt(j)=='X' && s[i].charAt(j+3)=='X' && s[i].charAt(j+6)=='X' && s[i].charAt(j+9)=='X'){
                    r+="4x3 ";c++;break;
                }
            for(int j=0;j<2;j++)
                if(s[i].charAt(j)=='X' && s[i].charAt(j+2)=='X' && s[i].charAt(j+4)=='X' && s[i].charAt(j+6)=='X' && s[i].charAt(j+8)=='X'&& s[i].charAt(j+10)=='X'){
                    r+="6x2 ";c++;break;
                }
            for(int j=0;j<12;j++)
                if(s[i].charAt(j)!='X'){
                    f=false;break;
                }
            if(f){
                r+="12x1 ";c++;
            }
            System.out.println(c+" "+r);
            c=0;r="";f=true;
        }

         //thanks

    }
}


import java.util.*;
public class tgrb{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int t=Integer.parseInt(sc.nextLine());
        String[]s=new String[t];int c=0;
        for(int i=0;i<t;i++)
            s[i]=sc.nextLine();
        String r="";boolean f=true;
        for(int i=0;i<t;i++){
            for(int j=0;j<12;j++)
                if(s[i].charAt(j)=='X'){
                    r+="1x12 ";c++;break;
                }
            for(int j=0;j<6;j++)
                if(s[i].charAt(j)=='X' && s[i].charAt(j+6)=='X'){
                    r+="2x6 ";c++;break;
                }
            for(int j=0;j<4;j++)
                if(s[i].charAt(j)=='X' && s[i].charAt(j+4)=='X' && s[i].charAt(j+8)=='X'){
                    r+="3x4 ";c++;break;
                }
            for(int j=0;j<3;j++)
                if(s[i].charAt(j)=='X' && s[i].charAt(j+3)=='X' && s[i].charAt(j+6)=='X' && s[i].charAt(j+9)=='X'){
                    r+="4x3 ";c++;break;
                }
            for(int j=0;j<2;j++)
                if(s[i].charAt(j)=='X' && s[i].charAt(j+2)=='X' && s[i].charAt(j+4)=='X' && s[i].charAt(j+6)=='X' && s[i].charAt(j+8)=='X'&& s[i].charAt(j+10)=='X'){
                    r+="6x2 ";c++;break;
                }
            for(int j=0;j<12;j++)
                if(s[i].charAt(j)!='X'){
                    f=false;break;
                }
            if(f){
                r+="12x1 ";c++;
            }
            System.out.println(c+" "+r);
            c=0;r="";f=true;
        }

    }
}


import java.util.*;
public class visiting {
public static void main(String[]args) {
	Scanner sc =new Scanner(System.in);
	int t=sc.nextInt();
	String s="";
	int c=0;
	boolean flag=false;
	String f="";
	for(int i=t;i>0;i--) {

s=sc.next();

flag=false;

for(int j=0;j<12;j++) {
		if (s.charAt(j)=='X')
			{flag=true;break;}}

     if (flag)
		{c++;
		f=f+" 1x12";}
 	flag=false;
     for(int k=0;k<6;k++) {
 		for(int j=k;j<12;j+=6) {
 		     if (s.charAt(j)=='O')
 		    	break	;
 		     else if(j>5)
 		    	flag=true;
 	}}
 	if (flag)
 		{c++;f=f+" 2x6";}

	flag=false;
	for(int k=0;k<4;k++) {
		for(int j=k;j<12;j+=4) {
		     if (s.charAt(j)=='O')
		    	break	;
		     else if(j>7)
		    	flag=true;
	}}
	if (flag)
		{c++;f=f+" 3x4";
		}
	flag=false;
	for(int k=0;k<3;k++) {
         for(int j=k;j<12;j+=3) {
        	 if (s.charAt(j)=='O')
                 break;
        	 else if (j>8)
        		 flag=true;
         }}
	if (flag)
		{c++;
		f=f+" 4x3";
		}

		flag=false;
		for(int k=0;k<2;k++) {
		for(int j=k;j<12;j+=2) {
			if (s.charAt(j)=='O')
				break;
			else if (j>9)
				flag=true;
		}}
		if (flag)
			{c++;
			f=f+" 6x2";
			}

	flag=false;
	for(int j=0;j<12;j++) {
		if (s.charAt(j)=='O')
			flag=true;
		}
	if(!flag)
		{c++;f=f+" 12x1";}

	System.out.print(c);
	System.out.print(f);
	System.out.println("");
	c=0;
	f="";
}}
}


import java.util.*;
public class visiting {
public static void main(String[]args) {
	Scanner sc =new Scanner(System.in);
	int t=sc.nextInt();
	String s="";
	int c=0;
	boolean flag=false;
	String f="";
	for(int i=t;i>0;i--) {

s=sc.next();

flag=false;

for(int j=0;j<12;j++) {
		if (s.charAt(j)=='X')
			{flag=true;break;} }

     if (flag)
		{c++;
		f=f+" 1x12";}
 	flag=false;
     for(int k=0;k<6;k++) {
 		for(int j=k;j<12;j+=6) {
 		     if (s.charAt(j)=='O')
 		    	break	;
 		     else if(j>5)
 		    	flag=true;
 	}}
 	if (flag)
 		{c++;f=f+" 2x6";}

	flag=false;
	for(int k=0;k<4;k++) {
		for(int j=k;j<12;j+=4) {
		     if (s.charAt(j)=='O')
		    	break	;
		     else if(j>7)
		    	flag=true;
	}}
	if (flag)
		{c++;f=f+" 3x4";
		}
	flag=false;
	for(int k=0;k<3;k++) {
         for(int j=k;j<12;j+=3) {
        	 if (s.charAt(j)=='O')
                 break;
        	 else if (j>8)
        		 flag=true;
         }}
	if (flag)
		{c++;
		f=f+" 4x3";
		}

		flag=false;
		for(int k=0;k<2;k++) {
		for(int j=k;j<12;j+=2) {
			if (s.charAt(j)=='O')
				break;
			else if (j>9)
				flag=true;
		}}
		if (flag)
			{c++;
			f=f+" 6x2";
			}

	flag=false;
	for(int j=0;j<12;j++) {
		if (s.charAt(j)=='O')
			flag=true;
		}
	if(!flag)
		{c++;f=f+" 12x1";}

	System.out.print(c);
	System.out.print(f);
	c=0;
	f="";
}}
}


import java.util.*;
public class visiting {
public static void main(String[]args) {
	Scanner sc =new Scanner(System.in);
	int t=sc.nextInt();
	String s="";
	int c=0;
	boolean flag=false;
	String f="";
	for(int i=t;i>0;i--) {

s=sc.next();

flag=false;

for(int j=0;j<12;j++) {
		if (s.charAt(j)=='X')
			{flag=true;break;}}

     if (flag)
		{c++;
		f=f+" 1x12";}
 	flag=false;
     for(int k=0;k<6;k++) {
 		for(int j=k;j<12;j+=6) {
 		     if (s.charAt(j)=='O')
 		    	break	;
 		     else if(j>5)
 		    	flag=true;
 	}}
 	if (flag)
 		{c++;f=f+" 2x6";}

	flag=false;
	for(int k=0;k<4;k++) {
		for(int j=k;j<12;j+=4) {
		     if (s.charAt(j)=='O')
		    	break	;
		     else if(j>7)
		    	flag=true;
	}}
	if (flag)
		{c++;f=f+" 3x4";
		}
	flag=false;
	for(int k=0;k<3;k++) {
         for(int j=k;j<12;j+=3) {
        	 if (s.charAt(j)=='O')
                 break;
        	 else if (j>8)
        		 flag=true;
         }}
	if (flag)
		{c++;
		f=f+" 4x3";
		}

		flag=false;
		for(int k=0;k<2;k++) {
		for(int j=k;j<12;j+=2) {
			if (s.charAt(j)=='O')
				break;
			else if (j>9)
				flag=true;
		}}
		if (flag)
			{c++;
			f=f+" 6x2";
			}

	flag=false;
	for(int j=0;j<12;j++) {
		if (s.charAt(j)=='O')
			flag=true;
		}
	if(!flag)
		{c++;f=f+" 12x1";}

	System.out.print(c);
	System.out.print(f);
	c=0;
	f="";
}}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

public class Train {
	public static void main(String args[]) throws IOException {
		EhabReader sc = new EhabReader();
		PrintWriter out = new PrintWriter(System.out);
		// code
		int n = sc.nextInt();
		String str = "";
		sc.readLine();
		for (int i = 0; i < n; i++) {
			String s = sc.readLine();
			out.print(check(s)+"\n");
		}
		out.flush();
		out.close();
	}

	private static String check(String s) {
		int sum = 0;
		String res = "";
		char[] str = new char[12];
		boolean flag = false;
		boolean flag2 = true;
		for (int i = 0; i < 12; i++) {
			str[i] = s.charAt(i);
			if (s.charAt(i) == 'X') {
				flag = true;
			} else {
				flag2 = false;
			}
		}
		if (flag) {
			sum++;
			res += "1x12";
			flag = false;
			for (int i = 0; i < 6; i++) {
				if (str[i] == str[i + 6] && str[i] == 'X') {
					flag = true;
					break;
				}
			}
			if (flag) {
				res += " 2x6";
				sum++;
				flag = false;
			}
			for (int i = 0; i < 4; i++) {
				if (str[i] == str[i + 4] && str[i + 4] == str[i + 8] && str[i] == 'X') {
					flag = true;
					break;
				}
			}
			if (flag) {
				res += " 3x4";
				sum++;
				flag = false;
			}
			for (int i = 0; i < 3; i++) {
				if (str[i] == str[i + 3] && str[i + 3] == str[i + 6] && str[i + 6] == str[i + 9] && str[i] == 'X') {
					flag = true;
					break;
				}
			}
			if (flag) {
				res += " 4x3";
				sum++;
				flag = false;
			}
			for (int i = 0; i < 2; i++) {
				if (str[i] == str[i + 2] && str[i + 2] == str[i + 4] && str[i + 4] == str[i + 6]
						&& str[i + 6] == str[i + 8] && str[i + 8] == str[i + 10] && str[i] == 'X') {
					flag = true;
					break;
				}
			}
			if (flag) {
				res += " 6x2";
				sum++;
			}
			if (flag2) {
				res += " 12x1";
				sum++;
			}
			return sum + " " + res;
		} else {
			return "0";
		}

	}

	static class EhabReader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public EhabReader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String nextLine() {
			// TODO Auto-generated method stub
			return null;
		}

		public EhabReader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[1000000]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}
}


import java.io.*;
import java.util.*;
public class zizo2{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		int t = Integer.parseInt(br.readLine());
		int[] columns = {6,4,3,2};
		int[] rows = {2,3,4,6};
		while(t-->0) {
			String x = br.readLine();
			boolean[] acc = new boolean[4];
			for(int i = 0; i<4; i++) {
				for(int j = 0; j<columns[i]; j++) {
					boolean zero = false;
					for(int k = j; k<x.length(); k+=columns[i]) {
						if(x.charAt(k)=='O') {
							zero = true;
							break;
						}
					}
					if(!zero) {
						acc[i] = true;
						break;
					}
				}
			}
			StringBuilder tmp = new StringBuilder();
			int num = 0;
			for(int i = 0 ; i<4; i++) {
				if(acc[i]==true) {
					num++;
					tmp.append(rows[i]+"x"+columns[i]+" ");
				}
			}
			boolean first = false;
			for(int i = 0; i<x.length(); i++)
				if(x.charAt(i)=='X') {
					num++;
					first = true;
					break;
				}
			boolean last = true;
			for(int i = 0 ; i<x.length(); i++)
				if(x.charAt(i)=='O') {
					last = false;
					break;
				}
			if(last)
				num++;
			if(num==0)
				out.println(num);
			else
				out.println(num+" "+(first?"1x12 ":"")+tmp+(last?"12x1":""));
		}
		out.flush();
		out.close();
	}
}


import java.io.BufferedReader;
import java.io.PrintWriter;

import java.io.InputStreamReader;

import java.io.IOException;

import java.util.StringTokenizer;

import java.util.Arrays;

public class Main {

    static Scanner in = new Scanner();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int n = in.nextInt();
        for(int i = 0; i < n; i++) {
            char[] c = in.next().toCharArray();
            StringBuilder sb = new StringBuilder();
            int v = 0, t = 0, l[] = {12, 6, 4, 3, 2, 1}, l2[] = {1, 2, 3, 4, 6, 12};
            for(int j = 0; j < 6; j++) {
                boolean b[] = new boolean[l[j]];
                for(int k = 0; k < l[j]; k++)
                    b[k] = true;
                for(int k = 0; k < 12; k++) {
                    int k2 = k % l[j];
                    b[k2] = b[k2] && (c[k] == 'X');
                }
                for(int k = 0; k < l[j]; k++) {
                    if(b[k]) {
                        k = l[j];
                        t++;
                        sb.append(" " + l2[j] + "x" + l[j]);
                    }
                }
            }
            out.print(t);
            out.println(sb);
        }
        out.close();
    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer("");
        }

        public String next() throws IOException {
            if(!st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            if(!st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            String r = st.nextToken("\n");
            st = new StringTokenizer(br.readLine(), " ");
            return r;
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}


import javafx.util.Pair;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main (String[] args) throws java.lang.Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] array = br.readLine().trim().split("\\s", -1);
        int t = Integer.parseInt(array[0]);

        List<Pair<Integer,Integer>> l = new ArrayList<>();
        l.add(new Pair<>(1,12));
        l.add(new Pair<>(2,6));
        l.add(new Pair<>(3,4));
        l.add(new Pair<>(4,3));
        l.add(new Pair<>(6,2));
        l.add(new Pair<>(12,1));

        while(t != 0){
            String s = br.readLine().trim();
            List<String> ans = new ArrayList<>();

            for(Pair<Integer,Integer> p : l){
                int a = p.getKey();
                int b = p.getValue();

                boolean res = false;

                for(int i=0;i<b;i++){
                    if(s.charAt(i) == 'X'){
                        int temp = b + i;
                        res = true;
                        while (temp < 12){
                            if(s.charAt(temp) != 'X'){
                                res = false;
                                break;
                            }
                            temp = temp + b;
                        }

                    }
                }

                if(res)
                    ans.add(p.getKey() + "x" + p.getValue());
            }

            String sol = ""+ans.size();
            for(String pair : ans){
                sol += " " + pair;
            }

            System.out.println(sol);
            t--;
        }

    }
}


import javafx.util.Pair;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main (String[] args) throws java.lang.Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] array = br.readLine().trim().split("\\s", -1);
        int t = Integer.parseInt(array[0]);

        List<Pair<Integer,Integer>> l = new ArrayList<>();
        l.add(new Pair<>(1,12));
        l.add(new Pair<>(2,6));
        l.add(new Pair<>(3,4));
        l.add(new Pair<>(4,3));
        l.add(new Pair<>(6,2));
        l.add(new Pair<>(12,1));

        while(t != 0){
            String s = br.readLine().trim();
            List<String> ans = new ArrayList<>();

            for(Pair<Integer,Integer> p : l){
                int a = p.getKey();
                int b = p.getValue();

                boolean res = false;

                for(int i=0;i<b;i++){
                    if(s.charAt(i) == 'X'){
                        int temp = b + i;
                        res = true;
                        while (temp < 12){
                            if(s.charAt(temp) != 'X'){
                                res = false;
                                break;
                            }
                            temp = temp + b;
                        }

                    }

                    if(res)
                        break;
                }

                if(res)
                    ans.add(p.getKey() + "x" + p.getValue());
            }

            String sol = ""+ans.size();
            for(String pair : ans){
                sol += " " + pair;
            }

            System.out.println(sol);
            t--;
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Choose {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int tc=sc.nextInt();
		while(tc-->0)
		{
			char []s=sc.nextLine().toCharArray();
			int cnt=0;
			StringBuilder sb=new StringBuilder();
			for(int row=1;row<=12;row++)
			{
				if(12%row!=0)
					continue;
				int col=12/row;
				boolean oK=false;
				for(int start=0;start<col;start++)
				{
					boolean ok=true;
					for(int k=start;k<12;k+=col)
					{
						if(s[k]!='X')
							ok=false;
					}
					if(ok)
						oK=true;
				}
				if(oK)
				{
					sb.append(" "+row+"X"+col);
					cnt++;
				}
			}
			System.out.print(cnt);
			System.out.println(sb);
		}

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public int  nextInt()  throws IOException
		{
			return Integer.parseInt(next());
		}
		public String next()  throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(nextLine());
			return st.nextToken();
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Choose {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int tc=sc.nextInt();
		while(tc-->0)
		{
			char []s=sc.nextLine().toCharArray();
			int cnt=0;
			StringBuilder sb=new StringBuilder();
			for(int row=1;row<=12;row++)
			{
				if(12%row!=0)
					continue;
				int col=12/row;
				boolean oK=false;
				for(int start=0;start<col;start++)
				{
					boolean ok=true;
					for(int k=start;k<12;k+=col)
					{
						if(s[k]!='X')
							ok=false;
					}
					if(ok)
						oK=true;
				}
				if(oK)
				{
					sb.append(" "+row+"x"+col);
					cnt++;
				}
			}
			System.out.print(cnt);
			System.out.println(sb);
		}

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public int  nextInt()  throws IOException
		{
			return Integer.parseInt(next());
		}
		public String next()  throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(nextLine());
			return st.nextToken();
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.StringTokenizer;

public class test {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for (int i = 0; i < t; i++) {
			String s = sc.nextLine();
			int count = 0;
			String out = "";
			for (int j = 1; j <= 12; j++) {

				int a = 0;
				int b = 0;

				if(12%j == 0){
					a = j;
					b = 12/a;

					for (int k = 0; k < b; k++) {
						boolean found = true;
						for (int k2 = k; k2 < 12; k2+=b) {
							if(s.charAt(k2) == 'O'){
								found = false;
								break;
							}

						}
						if(found){
							count = count + 1;
							out = out + " "+ a +"x" + b;
							break;
						}
					}
				}

			}
			System.out.println(count + out);

		}
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException
		{
			return Double.parseDouble(st.nextToken());
		}

		public boolean ready() throws IOException {return br.ready();}

	}

}


import java.io.*;
import java.util.StringTokenizer;
public class Main {
	public static void arr(int[]a,String x ){
		StringTokenizer st = new StringTokenizer(x);
		for(int i = 0;i<a.length;i++)
			a[i]=Integer.parseInt(st.nextToken());
	}
	public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String x = br.readLine();
StringTokenizer st = new StringTokenizer(x);
int n = Integer.parseInt(st.nextToken());
String r ="";
int c=1;
int v= 0;
for (int z=0 ;z<n;z++){
	x=br.readLine();
	for (int i=1;i<=12;i++){
		if(12%i==0)
		for(int j=0; j<12;j++){
		   	if(x.charAt(j)=='X')
		   		for(int m=j+i;m<12;m+=i )
		   			if (x.charAt(m)=='X')
						c++;
			if(i*c==12&&x.charAt(j)=='X')	{
				v++;
                r=" "+c+"x"+(i)+r;
             break;   }

               ;
			c=1;}}  System.out.println(v+r);r="";v=0;
}

}
	}


import java.io.*;
import java.util.StringTokenizer;
public class Main {
	public static void arr(int[]a,String x ){
		StringTokenizer st = new StringTokenizer(x);
		for(int i = 0;i<a.length;i++)
			a[i]=Integer.parseInt(st.nextToken());
	}
	public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String x = br.readLine();
StringTokenizer st = new StringTokenizer(x);
int n = Integer.parseInt(st.nextToken());
String r ="";
int c=1;
int v= 0;
for (int z=0 ;z<n;z++){
	x=br.readLine();
	for (int i=1;i<=12;i++){
		if(12%i==0){c=1;
		for(int j=0; j<12;j++){
		   	if(x.charAt(j)=='X')
		   		for(int m=j+(12/i);m<12;m+=(12/i) )
		   			if (x.charAt(m)=='X'){
						c++;	}
			if(i==c&&x.charAt(j)=='X')	{
				v++;
                r+=" "+c+"x"+(12/i);
             break;   }
			c=1;}}}  System.out.println(v+r);r="";v=0;
}

}
	}


		import java.util.*;
		import java.util.*;
		import javax.swing.plaf.synth.SynthSpinnerUI;
		import javax.swing.plaf.synth.SynthStyle;
		import java.io.BufferedReader;
		import java.io.IOException;
		import java.io.InputStreamReader;
		import java.util.StringTokenizer;
		import java.io.BufferedReader;
		import java.io.IOException;
		import java.io.InputStreamReader;

		public class mohamedy23
				{
			      public static void main (String args[])throws NumberFormatException, IOException
				    {
				    	Scanner sc=new Scanner(System.in);
				    	int t=sc.nextInt();
				    	for(int i=0;i<t;i++) {
				    		String s=sc.next();String b="";String p="";int u=0;
				    		if(s.contains("X")) {
				    			p=p+'1'+'x'+"12"+" ";u++;
				    		}if((s.charAt(0)=='X'&&s.charAt(6)=='X')||(s.charAt(1)=='X'&&s.charAt(7)=='X')
				    				||(s.charAt(2)=='X'&&s.charAt(8)=='X')||(s.charAt(3)=='X'&&s.charAt(9)=='X')
				    				||(s.charAt(4)=='X'&&s.charAt(10)=='X')||(s.charAt(5)=='X'&&s.charAt(11)=='X')) {

				    			p=p+'2'+'x'+'6'+" ";u++;}
				    		if((s.charAt(0)=='X'&&s.charAt(4)=='X'&&s.charAt(8)=='X')||
				    				(s.charAt(1)=='X'&&s.charAt(5)=='X'&&s.charAt(9)=='X')||
				    				(s.charAt(2)=='X'&&s.charAt(6)=='X'&&s.charAt(10)=='X')||
				    				(s.charAt(3)=='X'&&s.charAt(7)=='X'&s.charAt(11)=='X')) {
				    			p=p+'3'+'x'+'4'+" ";u++;
				    		}
				    		 if((s.charAt(0)=='X'&&s.charAt(3)=='X'&&s.charAt(6)=='X'&&s.charAt(9)=='X')
					    				||(s.charAt(1)=='X'&&s.charAt(4)=='X'&&s.charAt(7)=='X'&&s.charAt(10)=='X')
					    				||(s.charAt(2)=='X'&&s.charAt(5)=='X'&&s.charAt(8)=='X'&&s.charAt(11)=='X'))
					    			{p=p+'4'+'x'+'3'+" ";u++;}
				    		if((s.charAt(0)=='X'&&s.charAt(2)=='X'&&s.charAt(4)=='X'
				    				&&s.charAt(6)=='X'&&s.charAt(8)=='X'&&s.charAt(10)=='X')
				    				||(s.charAt(1)=='X'&&s.charAt(3)=='X'&&s.charAt(5)=='X'&&s.charAt(7)=='X'
				    				&&s.charAt(9)=='X'&&s.charAt(11)=='X')) {
				    			p=p+'6'+'x'+'2'+" ";u++;
				    		}

				    		 if(!s.contains("O")) {
				    			 p=p+"12"+'x'+'1'+" ";u++;
				    		 }
				    		 System.out.println(u+" "+p);

				    	}
				    }
				}


		import java.util.*;
		import java.util.*;
		import javax.swing.plaf.synth.SynthSpinnerUI;
		import javax.swing.plaf.synth.SynthStyle;
		import java.io.BufferedReader;
		import java.io.IOException;
		import java.io.InputStreamReader;
		import java.util.StringTokenizer;
		import java.io.BufferedReader;
		import java.io.IOException;
		import java.io.InputStreamReader;

		public class mohamedy23
				{
			      public static void main (String args[])throws NumberFormatException, IOException
				    {
				    	Scanner sc=new Scanner(System.in);
				    	int t=sc.nextInt();
				    	for(int i=0;i<t;i++) {
				    		String s=sc.next();String b="";String p="";int u=0;
				    		if(s.contains("X")) {
				    			p=p+'1'+'x'+"12"+" ";u++;
				    		}
				    		if((s.charAt(0)=='X'&&s.charAt(2)=='X'&&s.charAt(4)=='X'
				    				&&s.charAt(6)=='X'&&s.charAt(8)=='X'&&s.charAt(10)=='X')
				    				||(s.charAt(1)=='X'&&s.charAt(3)=='X'&&s.charAt(5)=='X'&&s.charAt(7)=='X'
				    				&&s.charAt(9)=='X'&&s.charAt(11)=='X')) {
				    			p=p+'6'+'x'+'2'+" ";u++;
				    		}
				    		 if((s.charAt(0)=='X'&&s.charAt(6)=='X')||(s.charAt(1)=='X'&&s.charAt(7)=='X')
				    				||(s.charAt(2)=='X'&&s.charAt(8)=='X')||(s.charAt(3)=='X'&&s.charAt(9)=='X')
				    				||(s.charAt(4)=='X'&&s.charAt(10)=='X')||(s.charAt(5)=='X'&&s.charAt(11)=='X')) {

				    			p=p+'2'+'x'+'6'+" ";u++;}
				    		if((s.charAt(0)=='X'&&s.charAt(4)=='X'&&s.charAt(8)=='X')||
				    				(s.charAt(1)=='X'&&s.charAt(5)=='X'&&s.charAt(9)=='X')||
				    				(s.charAt(2)=='X'&&s.charAt(6)=='X'&&s.charAt(10)=='X')||
				    				(s.charAt(3)=='X'&&s.charAt(7)=='X'&s.charAt(11)=='X')) {
				    			p=p+'3'+'x'+'4'+" ";u++;
				    		}
				    		 if((s.charAt(0)=='X'&&s.charAt(3)=='X'&&s.charAt(6)=='X'&&s.charAt(9)=='X')
				    				||(s.charAt(1)=='X'&&s.charAt(4)=='X'&&s.charAt(7)=='X'&&s.charAt(10)=='X')
				    				||(s.charAt(2)=='X'&&s.charAt(5)=='X'&&s.charAt(8)=='X'&&s.charAt(11)=='X'))
				    			{p=p+'4'+'x'+'3'+" ";u++;}
				    		 System.out.println(u+" "+p);

				    	}
				    }
				}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Smile {
	static Scanner in;
	static PrintWriter out;
	static int[] div = new int[]{12, 6, 4, 3, 2, 1};
	static List<Integer> q;

	static void funk(String seq) {
		for (int i = 0; i < 6; i++) {
			for (int j = 0; j < 12 / div[i]; j++) {
				int count = 0;
				for (int k = 0; k < div[i]; k++) {
					if (seq.charAt(12 / div[i] * k + j) == 'X') {
						count++;
					}
				}
				if (count == div[i]) {
					q.add(div[i]);
					break;
				}
			}
		}
		out.print(q.size() + " ");
		for (int i = 0; i < q.size(); i++) {
			out.print(q.get(i) + "x" + (12 / q.get(i)) + " ");
		}
		out.println();
	}

	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n = in.nextInt();
		String a = "";
		q = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			a = in.next();
			funk(a);
			q.clear();
		}

		out.close();
	}
}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Smile {
	static Scanner in;
	static PrintWriter out;
	static int[] div = new int[]{12, 6, 4, 3, 2, 1};
	static List<Integer> q;

	static void funk(String seq) {
		for (int i = 0; i < 6; i++) {
			for (int j = 0; j < 12 / div[i]; j++) {
				int count = 0;
				for (int k = 0; k < div[i]; k++) {
					if (seq.charAt(12 / div[i] * k + j) == 'X') {
						count++;
					}
				}
				if (count == div[i]) {
					q.add(div[i]);
					break;
				}
			}
		}
		out.print(q.size() + " ");
		for (int i = q.size() - 1; i >= 0; i--) {
			out.print(q.get(i) + "x" + (12 / q.get(i)) + " ");
		}
		out.println();
	}

	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n = in.nextInt();
		String a = "";
		q = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			a = in.next();
			funk(a);
			q.clear();
		}

		out.close();
	}
}


import java.io.File;

import java.util.Scanner;

/**
 *
 * @author lab H014-17
 */
public class AACCMM {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)  {
        Scanner in=new Scanner(System.in);
        int t=in.nextInt();
        String s;int c=0;String out="";
        while(t!=0){
            c=0;out="";
            s=in.next();
            if(is1X12(s)){
                c++;
                out+=" 1x12";
            }
             if(is2X6(s)){
                c++;
                out+=" 2x6";
            }

             if(is3X4(s)){
                c++;
                out+=" 3x4";
            }
                if(is4X3(s)){
                c++;
                out+=" 4x3";
            }
                if(is6X2(s)){
                c++;
                out+=" 6x2";
            }
                   if(is12X1(s)){
                c++;
                out+=" 12x1";

            }    System.out.print(c);
               System.out.println(out); t--;}

    }
    static boolean is1X12(String s){
      if(s.indexOf('X')<0)return false;
       return true;

    }
    static boolean is2X6(String s){
            for (int i = 0; i < 6; i++) {
            if(s.charAt(i)=='X'&&s.charAt(i+6)=='X')
                return true;
        }
            return false;
            }
    static boolean is3X4(String s){
            for (int i = 0; i < 4; i++) {
            if(s.charAt(i)=='X'&&s.charAt(i+4)=='X'&&s.charAt(i+8)=='X')
                return true;
        }
            return false;
            }
     static boolean is4X3(String s){
            for (int i = 0; i < 3; i++) {
            if(s.charAt(i)=='X'&&s.charAt(i+3)=='X'&&s.charAt(i+6)=='X'&&s.charAt(i+9)=='X')
                return true;
        }
            return false;
            }
      static boolean is6X2(String s){
            for (int i = 0; i < 2; i++) {
            if(s.charAt(i)=='X'&&s.charAt(i+2)=='X'&&s.charAt(i+4)=='X'&&s.charAt(i+6)=='X'&&s.charAt(i+8)=='X'&&s.charAt(i+10)=='X')
                return true;
        }
            return false;
            }
      static boolean is12X1(String s){
            if(s.equals("XXXXXXXXXXXX"))return true;
            return false;
            }
}


import java.util.*;
public class Main{
	public static void main(String[] args)
	  {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		for(int j=0;j<t;j++) {
		String s=sc.next();

		String s2a="";
		String s2b="";
		String s3a="";
		String s3b="";
		String s3c="";
		String s4a="";
		String s4b="";
		String s4c="";
		String s4d="";
		String s6a="";
		String s6b="";
		String s6c="";
		String s6d="";
		String s6e="";
		String s6f="";
		String sol="";

		int ways=0;
		if(s.contains("X")) {
			ways++;
			sol+="1x12 ";
		}

		for(int i=0;i<7;i+=6) {
			s6a+=s.charAt(i);
			s6b+=s.charAt(i+1);
			s6c+=s.charAt(i+2);
			s6d+=s.charAt(i+3);
			s6e+=s.charAt(i+4);
			s6f+=s.charAt(i+5);
		}
		if(!s6a.contains("O")||!s6b.contains("O")||!s6c.contains("O")||!s6d.contains("O")||!s6e.contains("O")||!s6f.contains("O")) {
			ways++;
			sol+="2x6 ";
		}

		for(int i=0;i<9;i+=4) {
			s4a+=s.charAt(i);
			s4b+=s.charAt(i+1);
			s4c+=s.charAt(i+2);
			s4d+=s.charAt(i+3);

		}
		if(!s4a.contains("O")||!s4b.contains("O")||!s4c.contains("O")||!s4d.contains("O")) {
			ways++;
			sol+="3x4 ";
		}
		for(int i=0;i<10;i+=3) {
			s3a+=s.charAt(i);
			s3b+=s.charAt(i+1);
			s3c+=s.charAt(i+2);
		}

		if(!s3a.contains("O")||!s3b.contains("O")||!s3c.contains("O")) {
			ways++;
			sol+="4x3 ";
		}
		for(int i=0;i<11;i+=2) {
			s2a+=s.charAt(i);
			s2b+=s.charAt(i+1);
		}
		if(!s2a.contains("O")||!s2b.contains("O")) {
			ways++;
			sol+="6x2 ";
		}

		if(!s.contains("O")) {
			ways++;
		    sol+="12x1 ";
		    }
		System.out.println(ways+" "+sol);
	}
	  }
}


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;

public class A_400 implements Runnable{

    public void solve(){
        int tc = scan.nextInt();
        while(tc--!=0){
            char ar[]= scan.next().toCharArray();
            int n = ar.length;
            int dp1[] = new int[n];
            int m1=0,m2=0,m3=0,m4=0,m5=0;
            int dp2[] = new int[n];
            int dp3[] = new int[n];
            int dp4[] = new int[n];
            int dp5[] = new int[n];
            boolean found = false;
            for(int i=0;i<n;i++){
                if(ar[i]=='X'){
                    found = true;
                    if(i-1>=0){
                        if(ar[i-1]=='X') dp1[i] = 1+dp1[i-1];
                    }
                    if(i-2>=0){
                        if(ar[i-2]=='X') dp2[i] = 1+dp2[i-2];
                    }
                    if(i-3>=0){
                        if(ar[i-3]=='X') dp3[i] = 1+dp3[i-3];
                    }
                    if(i-4>=0){
                        if(ar[i-4]=='X') dp4[i] = 1+dp4[i-4];
                    }
                    if(i-6>=0){
                        if(ar[i-6]=='X') dp5[i] = 1+dp5[i-6];
                    }
                }
                m1 = Math.max(m1,dp1[i]);
                m2 = Math.max(m2,dp2[i]);
                m3 = Math.max(m3,dp3[i]);
                m4 = Math.max(m4,dp4[i]);
                m5 = Math.max(m5,dp5[i]);
            }
            int count =0;
            StringBuilder sb = new StringBuilder();
            m1++ ;m2++ ;m3++ ;m4++ ;m5++;
            if(found){
                sb.append("1x12 ");count++;
            }
            if(m5==2)
            {sb.append("2x6 ");count++;}
            if(m4==3)
            {sb.append("3x4 ");count++;}
            if(m3==4)
            {sb.append("4x3 ");count++;}
            if(m2==6)
            {sb.append("6x2 ");count++;}
            if(m1==12)
            {sb.append("12x1 ");count++;}
            System.out.println(count+ " "+sb.toString().trim());
        }
    }

    InputReader scan;
    PrintWriter out;

    @Override
    public void run(){
        scan = new InputReader(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.flush();
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null,new A_400(),"Main",1<<26).start();
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt() {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
                return res * sgn;
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;

public class InnaAndChooseOptions
{
	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		int t = Integer.parseInt(br.readLine());
		int counter = 0;
		while( counter < t )
		{
			int count = 0;
			StringBuilder sol = new StringBuilder();
			StringBuilder s = new StringBuilder(br.readLine());
			ArrayList<Character> a = new ArrayList<Character>();
			for(int g = 0; g < 12; g++)
				a.add(s.charAt(g));

			if( containsX(s) )
			{
				count++;
				sol.append("1x12 ");
			}

			for(int i = 0; i < 6; i++)
			{
				if( a.get(i) == a.get(i+6) && a.get(i) == 'X' )
				{
					count++;
					sol.append("2x6 ");
					break;
				}
			}

			for(int i = 0; i < 4; i++)
			{
				if( a.get(i) == a.get(i+4) && a.get(i) == a.get(i+8) && a.get(i) == 'X' )
				{
					count++;
					sol.append("3x4 ");
					break;
				}
			}

			for(int i = 0; i < 3; i++)
			{
				if( a.get(i) == a.get(i+3) && a.get(i) == a.get(i+6) && a.get(i) == a.get(i+9) && a.get(i) == 'X' )
				{
					count++;
					sol.append("4x3 ");
					break;
				}
			}

			for(int i = 0; i < 2; i++)
			{
				if( a.get(i) == a.get(i+2) && a.get(i) == a.get(i+4) && a.get(i) == a.get(i+6) && a.get(i) == a.get(i+8) && a.get(i) == a.get(i+10) && a.get(i) == 'X' )
				{
					count++;
					sol.append("6x2 ");
					break;
				}
			}

			if( !containsO(s) )
			{
				count++;
				sol.append("12x1 ");
			}

			sol.insert(0, count);
			sol.insert(1, ' ');
			out.println(sol);
			counter++;
		}
		out.flush();
	}

	public static boolean containsX(StringBuilder s)
	{
		for(int i = 0; i < s.length(); i++)
			if( s.charAt(i) == 'X' )
				return true;
		return false;
	}

	public static boolean containsO(StringBuilder s)
	{
		for(int i = 0; i < s.length(); i++)
			if( s.charAt(i) == 'O' )
				return true;
		return false;
	}
}


// 15.11.19 , 9:01
// ...
// a...a
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define f first
#define pb push_back
#define mp make_pair
#define WrongAnswer 0
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define bye exit(0)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef tree <ll ,null_type,less <ll> ,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = (int)1e6 + 11, inf = 1e9, mod = 1e9 + 7;

int n , a[N] , d;

set <int> s;

vector <int> ans;

set <int> used;
inline void cheetah(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main(){
  cheetah();
  cin >> n;
  for(int i = 1 ; i <= n ; ++i)
    cin >> a[i];

  for(int i = 1 ; i <= n ; ++i){
    if(a[i] > 0 && s.find(a[i]) == s.end() &&used.find(a[i]) == used.end()){
       used.insert(a[i]);
       s.insert(a[i]);
    }
    else if(a[i] < 0 && s.find(-a[i]) != s.end())
       s.erase(s.find(-a[i]));
    else{
       cout << "-1";
       bye;
    }
    if(s.size() == 0){
       ans.pb(i);
       used.clear();
    }
  //  cout << s.size() << " " ;
  }
  if(s.size())
    cout << -1;
  else{
    cout << ans.size()  << " ";
    for(int i = 0 ; i < ans.size() ; ++i)
      cout << ans[i] - ans[i - 1] << " ";
  }

  return false;
}


// 15.11.19 , 9:01
// ...
// a...a
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define f first
#define pb push_back
#define mp make_pair
#define WrongAnswer 0
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define bye exit(0)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef tree <ll ,null_type,less <ll> ,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = (int)1e6 + 11, inf = 1e9, mod = 1e9 + 7;

int n , a[N] , d;

set <int> s;

vector <int> ans;

set <int> used;
inline void cheetah(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main(){
  cheetah();
  cin >> n;
  for(int i = 1 ; i <= n ; ++i)
    cin >> a[i];

  for(int i = 1 ; i <= n ; ++i){
    if(a[i] > 0 && s.find(a[i]) == s.end() &&used.find(a[i]) == used.end()){
       used.insert(a[i]);
       s.insert(a[i]);
    }
    else if(a[i] < 0 && s.find(-a[i]) != s.end())
       s.erase(s.find(-a[i]));
    else{
       cout << "-1";
       return false;
    }
	if(s.size() == 0){
	  ans.pb(i);
	  used.clear();
	}
  //  cout << s.size() << " " ;
  }
  if(s.size())
    cout << -1;
  else{
     cout << ans.size()  << " ";
     for(int i = 0 ; i < ans.size() ; ++i)
       cout << ans[i] - ans[i - 1] << " ";
  }

  return false;
}


// 15.11.19 , 9:01
// ...
// a...a
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define f first
#define pb push_back
#define mp make_pair
#define WrongAnswer 0
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define bye exit(0)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef tree <ll ,null_type,less <ll> ,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = (int)1e6 + 11, inf = 1e9, mod = 1e9 + 7;

int n , a[N] , d;

vector <int> ans , used, s;

inline void cheetah(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main(){
  cheetah();
  cin >> n;
  ans.pb(0);
  for(int i = 1 ; i <= n ; ++i)
    cin >> a[i];

  for(int i = 1 ; i <= n ; ++i){
    if(a[i] > 0 && find(s.begin(),s.end(),a[i]) == s.end() && find(used.begin(),used.end(),a[i]) == used.end()){
      used.push_back(a[i]);
      s.push_back(a[i]);
    }
    else if(a[i] < 0 && find(s.begin(),s.end(),-a[i]) != s.end())
      s.erase(find(s.begin(),s.end(),-a[i]));
    else{
      cout << "-1";
      bye;
    }
    if(s.size() == 0){
      ans.push_back(i);
      used.clear();
    }
  //  cout << s.size() << " " ;
  }
  if(s.size())
    cout << -1;
  else{
    cout << ans.size()- 1 << "\n";
    for(int i = 1 ; i < ans.size() ; ++i)
      cout << ans[i] - ans[i - 1] << " ";
  }

  return false;
}


// 15.11.19 , 9:01
// ...
// a...a
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define f first
#define pb push_back
#define mp make_pair
#define WrongAnswer 0
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define bye exit(0)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef tree <ll ,null_type,less <ll> ,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = (int)1e5 + 11, inf = 1e9, mod = 1e9 + 7;

int n , a[N] , d;

set <int> s;

vector <int> ans;

set <int> used;
inline void cheetah(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main(){
  cheetah();
  cin >> n;
  ans.pb(0);
  for(int i = 1 ; i <= n ; ++i)
    cin >> a[i];

  for(int i = 1 ; i <= n ; ++i){
    if(a[i] > 0 && s.find(a[i]) == s.end() &&used.find(a[i]) == used.end()){
       used.insert(a[i]);
       s.insert(a[i]);
    }
    else if(a[i] < 0 && s.find(-a[i]) != s.end())
       s.erase(s.find(-a[i]));
    else{
       cout << "-1";
       bye;
    }
    if(s.size() == 0){
       ans.pb(i);
       used.clear();
    }
  //  cout << s.size() << " " ;
  }
  if(s.size())
    cout << -1;
  else{
    cout << ans.size() - 1 << " ";
    for(int i = 1 ; i < ans.size(); ++i)
      cout << ans[i] - ans[i - 1] << " ";
  }


// 15.11.19 , 9:01
// ...
// a...a
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define f first
#define pb push_back
#define mp make_pair
#define WrongAnswer 0
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define bye exit(0)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef tree <ll ,null_type,less <ll> ,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = (int)1e5 + 11, inf = 1e9, mod = 1e9 + 7;

int n , a[N] , d;

set <int> s;

vector <int> ans;

set <int> used;
inline void cheetah(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main(){
  cheetah();
  cin >> n;
  ans.pb(0);
  for(int i = 1 ; i <= n ; ++i)
    cin >> a[i];

  for(int i = 1 ; i <= n ; ++i){
    if(a[i] > 0 && s.find(a[i]) == s.end() &&used.find(a[i]) == used.end()){
       used.insert(a[i]);
       s.insert(a[i]);
    }
    else if(a[i] < 0 && s.find(-a[i]) != s.end())
       s.erase(s.find(-a[i]));
    else{
       cout << "-1";
       bye;
    }
    if(s.size() == 0){
       ans.pb(i);
       used.clear();
    }
  //  cout << s.size() << " " ;
  }
  if(s.size())
    cout << -1;
  else{
    cout << ans.size() - 1 << " ";
    for(int i = 0 ; i < ans.size() - 1 ; ++i)
      cout << ans[i] - ans[i - 1] << " ";
  }

  return false;
}


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

#define ll long long
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef pair<int, int> pis;

int vis[maxn];
vector<int>ans;

int main() {
	int n;
	cin >> n;
	ll t = 0;
	memset(vis, 0, sizeof(vis));
	ans.push_back(0);
	for (int i = 1; i <= n; i ++) {
		int x;
		cin >> x;
		t += x;
		if(x > 0) vis[x] ++;
		if(vis[abs(x)] > 1) {
			cout << -1 << endl;
			return 0;
		}else if(x < 0 && vis[-x] == 0) {
			cout << -1 << endl;
			return 0;
		}
		if(t == 0) {
			ans.push_back(i);
			memset(vis, 0, sizeof(vis));
		}
	}
	if(t != 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans.size() - 1 << endl;
	for (int i = 1; i < ans.size(); i ++)
		cout << ans[i] - ans[i-1] << " ";

    return 0;
}


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

#define ll long long
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef pair<int, int> pis;

int vis[maxn];
vector<int>ans;

int main() {
	int n;
	scanf("%d", &n);
	ll t = 0;
	memset(vis, 0, sizeof(vis));
	ans.push_back(0);
	for (int i = 1; i <= n; i ++) {
		int x;
		scanf("%d", &x);
		t += x;
		if(x > 0) vis[x] ++;
		if(vis[abs(x)] > 1) {
			printf("-1\n");
			return 0;
		}else if(x < 0 && vis[-x] == 0) {
			printf("-1\n");
			return 0;
		}
		if(t == 0) {
			ans.push_back(i);
			memset(vis, 0, sizeof(vis));
		}
	}
	if(t != 0) {
		printf("-1\n");
		return 0;
	}
	printf("%d\n", ans.size() - 1);
	for (int i = 1; i < ans.size(); i ++)
		printf("%d ", ans[i] - ans[i-1]);
    return 0;
}


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

#define ll long long
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef pair<int, int> pis;

int vis[maxn];
vector<int>ans;

int main() {
	int n;
	scanf("%d", &n);
	ll t = 0;
	memset(vis, 0, sizeof(vis));
	ans.push_back(0);
	for (int i = 1; i <= n; i ++) {
		int x;
		scanf("%d", &x);
		t += x;
		if(x > 0) vis[x] ++;
		/*if(vis[x] > 1) {
			printf("-1\n");
			return 0;
		}else if(x < 0 && vis[-x] == 0) {
			printf("-1\n");
			return 0;
		}*/
		if(t == 0) {
			ans.push_back(i);
			memset(vis, 0, sizeof(vis));
		}
	}
	if(t != 0) {
		printf("-1\n");
		return 0;
	}
	printf("%d\n", ans.size()-1);
	for (int i = 1; i < ans.size(); i ++) {
		printf("%d ", ans[i] - ans[i-1]);
	}
    return 0;
}


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

#define ll long long
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef pair<int, int> pis;

int a[maxn];
map<int, int> vis;
vector<int>ans;

int main() {
		int n;
		scanf("%d", &n);
		ll t = 0;
		ans.push_back(0);
		for (int i = 1; i <= n; i ++) {
			scanf("%d", &a[i]);
			t += a[i];
			vis[a[i]] ++;
			if(vis[a[i]] > 1) {
				printf("-1\n");
				return 0;
			}
			if(t == 0) {
				ans.push_back(i);
				vis.clear();
			}
		}
		if(t) {
			printf("-1\n");
			return 0;
		}
		printf("%d\n", ans.size()-1);
		for (int i = 1; i < ans.size(); i ++)
			printf("%d ", ans[i] - ans[i-1]);
		return 0;
}


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

#define ll long long
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef pair<int, int> pis;

int vis[maxn], a[maxn];
vector<int>ans;

int main() {
	int n;
	scanf("%d", &n);
	memset(vis, 0, sizeof(vis));
	ans.push_back(0);
	int pre = 0;
	for (int i = 1, x; i <= n; i ++) {
		scanf("%d", &x);
		a[i] = a[i-1] + x;
		if(x < 0) {
			int px = vis[-x];
			if(px <= pre) {
				printf("-1\n");
				return 0;
			}
			if(a[i] - a[pre] == 0) {
				ans.push_back(i);
				pre = i;
			}
		}else {
			if(vis[x] > pre) {
				printf("-1\n");
				return 0;
			}
			vis[x] = i;
		}
	}
	printf("%d\n", ans.size() - 1);
	for (int i = 1; i < ans.size(); i ++)
		printf("%d ", ans[i] - ans[i-1]);
    return 0;
}


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

#define ll long long
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef pair<int, int> pis;

int a[maxn];
map<int, int> vis;
vector<int>ans;

int main() {
		int n;
		scanf("%d", &n);
		ll t = 0;
		ans.push_back(0);
		for (int i = 1; i <= n; i ++) {
			int x;
			scanf("%d", &x);
			t += x;
			if(x > 0) {
				vis[x] ++;
				if(vis[x] > 1) {
					printf("-1\n");
					return 0;
				}
			}else {
				if(vis[-x] == 0 || vis[-x] > 1) {
					printf("-1\n");
					return 0;
				}
			}
			if(t == 0) {
				ans.push_back(i);
				vis.clear();
			}
		}
		if(t) {
			printf("-1\n");
			return 0;
		}
		printf("%d\n", ans.size()-1);
		for (int i = 1; i < ans.size(); i ++)
			printf("%d ", ans[i] - ans[i-1]);
		return 0;
}


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

#define ll long long
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef pair<int, int> pis;

int vis[maxn], a[maxn];
vector<int>ans;

int main() {
	int n;
	scanf("%d", &n);
	memset(vis, 0, sizeof(vis));
	ans.push_back(0);
	int pre = 0;
	for (int i = 1, x; i <= n; i ++) {
		scanf("%d", &x);
		a[i] = a[i-1] + x;
		if(x < 0) {
			int px = vis[-x];
			if(px < pre) {
				printf("%d %d\n", x, px);
				printf("-1\n");
				return 0;
			}
			if(a[i] - a[pre] == 0) {
				ans.push_back(i);
				pre = i;
			}
		}else {
			if(vis[x] > pre) {
				printf("-1\n");
				return 0;
			}
			vis[x] = i;
		}
	}
	printf("%d\n", ans.size() - 1);
	for (int i = 1; i < ans.size(); i ++)
		printf("%d ", ans[i] - ans[i-1]);
    return 0;
}


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

#define ll long long
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef pair<int, int> pis;

int vis[maxn];
vector<int>ans;

int main() {
	int n;
	scanf("%d", &n);
	ll t = 0;
	memset(vis, 0, sizeof(vis));
	ans.push_back(0);
	for (int i = 1; i <= n; i ++) {
		int x;
		scanf("%d", &x);
		t += x;
		if(x > 0) vis[x] ++;
		if(vis[abs(x)] > 1) {
			printf("-1\n");
			return 0;
		}else if(x < 0 && vis[-x] == 0) {
			printf("-1\n");
			return 0;
		}
		if(t == 0) {
			ans.push_back(i);
			memset(vis, 0, sizeof(vis));
		}
	}
	if(t != 0) {
		printf("-1\n");
		return 0;
	}
	printf("%d\n", ans.size() - 1);
	for (int i = 1; i < ans.size(); i ++)
		printf("%d ", ans[i] - ans[i-1]);
    return 0;
}


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

#define ll long long
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef pair<int, int> pis;

int vis[maxn], a[maxn];
vector<int>ans;

int main() {
	int n;
	scanf("%d", &n);
	memset(vis, 0, sizeof(vis));
	ans.push_back(0);
	int pre = 0;
	for (int i = 1, x; i <= n; i ++) {
		scanf("%d", &x);
		a[i] = a[i-1] + x;
		if(x < 0) {
			int px = vis[-x];
			if(px <= pre) {
				printf("%d %d\n", x, px);
				printf("-1\n");
				return 0;
			}
			if(a[i] - a[pre] == 0) {
				ans.push_back(i);
				pre = i;
			}
		}else {
			if(vis[x] > pre) {
				printf("-1\n");
				return 0;
			}
			vis[x] = i;
		}
	}
	printf("%d\n", ans.size() - 1);
	for (int i = 1; i < ans.size(); i ++)
		printf("%d ", ans[i] - ans[i-1]);
    return 0;
}


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

#define ll long long
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef pair<int, int> pis;

int vis[maxn];
vector<int>ans;

int main() {
	int n;
	cin >> n;
	ll t = 0;
	memset(vis, 0, sizeof(vis));
	ans.push_back(0);
	for (int i = 1; i <= n; i ++) {
		int x;
		cin >> x;
		t += x;
		if(x > 0) vis[x] ++;
		if(vis[abs(x)] > 1) {
			cout << -1 << endl;
			return 0;
		}else if(x < 0 && vis[-x] == 0) {
			cout << -1 << endl;
			return 0;
		}
		if(t == 0) {
			ans.push_back(i);
			memset(vis, 0, sizeof(vis));
		}
	}
	if(t != 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans.size() - 1 << endl;
	for (int i = 1; i < ans.size(); i ++)
		cout << ans[i] - ans[i-1] << " ";

    return 0;
}


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

#define ll long long
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef pair<int, int> pis;

int vis[maxn];
vector<int>ans;

int main() {
	int n;
	scanf("%d", &n);
	ll t = 0;
	memset(vis, 0, sizeof(vis));
	ans.push_back(0);
	for (int i = 1; i <= n; i ++) {
		int x;
		scanf("%d", &x);
		t += x;
		if(x > 0) vis[x] ++;
		if(vis[x] > 1) {
			printf("-1\n");
			return 0;
		}else if(x < 0 && vis[-x] == 0) {
			printf("-1\n");
			return 0;
		}
		if(t == 0) {
			ans.push_back(i);
			memset(vis, 0, sizeof(vis));
		}
	}
	if(t != 0) {
		printf("-1\n");
		return 0;
	}/*
	printf("%d\n", ans.size()-1);
	for (int i = 1; i < ans.size(); i ++) {
		printf("%d ", ans[i] - ans[i-1]);
	}*/
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
int a[N],pos[N*10];
int f[N];
bool vis[N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    bool ff=true;
    for(int i=1;i<=n;i++) {
        if(a[i]>0) {
            if(pos[a[i]]) ff=false;
            else pos[a[i]]=i;
        }
        else {
            if(!pos[-a[i]]) ff=false;
            else f[pos[-a[i]]]=i,pos[-a[i]]=0;
        }
    }
    if(!ff) printf("-1\n");
    else {
        vector<int> vec;
        for(int i=1,j;i<=n;) {
            int t=f[i];
            for(j=i;j<=t;j++) {
                t=max(t,f[j]);
            }
            vec.push_back(j-i);
            i=j;
        }
        int la=1;
        for(int i=0;i<vec.size();i++) {
            int lb=la+vec[i]-1;
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                if(vis[a[j]]) ff=false;
                vis[a[j]]=true;
            }
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                vis[a[j]]=false;
            }
            la+=vec[i];
        }
        if(!ff) printf("-1\n");
        else {
            printf("%d\n",vec.size());
            for(int i=0;i<vec.size();i++) {
                printf("%d%c",vec[i],i==vec.size()-1?'\n':' ');
            }
        }
    }
    return 0;
}
/*6
2 1 -1 1 -2 -1
*/


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
int a[N],f[N];
bool vis[N*10];
unordered_map<int,int> pos;
vector<int> vec;
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    bool ff=true;
    for(int i=1;i<=n;i++) {
        if(a[i]>0) {
            if(pos[a[i]]) ff=false;
            else pos[a[i]]=i;
        }
        else {
            if(!pos[-a[i]]) ff=false;
            else f[pos[-a[i]]]=i,pos[-a[i]]=0;
        }
    }
    if(!ff) printf("-1\n");
    else {
        for(int i=1,j;i<=n;) {
            int t=f[i];
            for(j=i;j<=t;j++) {
                t=max(t,f[j]);
            }
            vec.push_back(j-i);
            i=j;
        }
        int la=1;
        for(int i=0;i<vec.size();i++) {
            int lb=la+vec[i]-1;
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                if(vis[a[j]]) ff=false;
                vis[a[j]]=true;
            }
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                vis[a[j]]=false;
            }
            la+=vec[i];
        }
        if(!ff) printf("-1\n");
        else {
            printf("%d\n",vec.size());
            for(int i=0;i<vec.size();i++) {
                printf("%d%c",vec[i],i==vec.size()-1?'\n':' ');
            }
        }
    }
    return 0;
}
/*6
2 1 -1 1 -2 -1
*/


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5,M=1e6+5;
int a[N],f[N],pos[M];
bool vis[M];
vector<int> vec;
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    bool ff=true;
    for(int i=1;i<=n;i++) {
        if(a[i]>0) {
            if(pos[a[i]]) ff=false;
            else pos[a[i]]=i;
        }
        else {
            if(!pos[-a[i]]) ff=false;
            else f[pos[-a[i]]]=i,pos[-a[i]]=0;
        }
    }
    if(!ff) printf("-1\n");
    else {
        for(int i=1,j;i<=n;) {
            int t=f[i];
            for(j=i+1;j<=t;j++) {
                t=max(t,f[j]);
            }
            vec.push_back(j-i);
            if(vec.size()>N) {
                ff=false;
                break;
            }
            i=j;
        }
        int la=1;
        for(int i=0;i<vec.size();i++) {
            int lb=la+vec[i]-1;
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                if(vis[a[j]]) ff=false;
                vis[a[j]]=true;
            }
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                vis[a[j]]=false;
            }
            la+=vec[i];
        }
        if(!ff) printf("-1\n");
        else {
            printf("%d\n",vec.size());
            for(int i=0;i<vec.size();i++) {
                printf("%d%c",vec[i],i==vec.size()-1?'\n':' ');
            }
        }
    }
    return 0;
}
/*6
2 1 -1 1 -2 -1
*/


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
int a[N],pos[N*10];
int f[N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    bool ff=true;
    for(int i=1;i<=n;i++) {
        if(a[i]>0) {
            if(pos[a[i]]) ff=false;
            else pos[a[i]]=i;
        }
        else {
            if(!pos[-a[i]]) ff=false;
            else f[pos[-a[i]]]=i,pos[-a[i]]=0;
        }
    }
    if(!ff) printf("-1\n");
    else {
        vector<int> vec;
        for(int i=1,j;i<=n;) {
            int t=f[i];
            for(j=i;j<=t;j++) {
                t=max(t,f[j]);
            }
            vec.push_back(j-i);
            i=j;
        }
        int la=1;
        for(int i=0;i<vec.size();i++) {
            int lb=la+vec[i]-1;
            unordered_map<int,int> ma;
            for(int j=la;j<=lb;j++) {
                if(ma[a[j]]) ff=false;
                ma[a[j]]=1;
            }
            la+=vec[i];
        }
        if(!ff) printf("-1\n");
        else {
            printf("%d\n",vec.size());
            for(int i=0;i<vec.size();i++) {
                printf("%d%c",vec[i],i==vec.size()-1?'\n':' ');
            }
        }
    }
    return 0;
}
/*6
2 1 -1 1 -2 -1
*/


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5,M=1e6+5;
int a[N],f[N],pos[M];
bool vis[M];
vector<int> vec;
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    bool ff=true;
    for(int i=1;i<=n;i++) {
        if(a[i]>0) {
            if(pos[a[i]]) ff=false;
            else pos[a[i]]=i;
        }
        else {
            if(!pos[-a[i]]) ff=false;
            else f[pos[-a[i]]]=i,pos[-a[i]]=0;
        }
    }
    if(!ff) printf("-1\n");
    else {
        for(int i=1,j;i<=n;) {
            if(a[i]<0) continue;
            int t=f[i];
            for(j=i+1;j<=t;j++) {
                t=max(t,f[j]);
            }
            vec.push_back(j-i);
            i=j;
        }
        int la=1;
        for(int i=0;i<vec.size();i++) {
            int lb=la+vec[i]-1;
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                if(vis[a[j]]) ff=false;
                vis[a[j]]=true;
            }
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                vis[a[j]]=false;
            }
            la+=vec[i];
        }
        if(!ff) printf("-1\n");
        else {
            printf("%d\n",vec.size());
            for(int i=0;i<vec.size();i++) {
                printf("%d%c",vec[i],i==vec.size()-1?'\n':' ');
            }
        }
    }
    return 0;
}
/*6
2 1 -1 1 -2 -1
*/


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5,M=1e6+5;
int a[N],f[N],pos[M];
bool vis[M];
vector<int> vec;
int main() {
    int n,x=0,y=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        if(a[i]>0) x++;
        else y++;
    }
    bool ff=true;
    if(x!=y) ff=false;
    for(int i=1;i<=n;i++) {
        if(a[i]>0) {
            if(pos[a[i]]) ff=false;
            else pos[a[i]]=i;
        }
        else {
            if(!pos[-a[i]]) ff=false;
            else f[pos[-a[i]]]=i,pos[-a[i]]=0;
        }
    }
    if(!ff) printf("-1\n");
    else {
        for(int i=1,j;i<=n;) {
            int t=f[i];
            for(j=i+1;j<=t;j++) {
                t=max(t,f[j]);
            }
            vec.push_back(j-i);
            i=j;
        }
        int la=1;
        for(int i=0;i<vec.size();i++) {
            int lb=la+vec[i]-1;
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                if(vis[a[j]]) ff=false;
                vis[a[j]]=true;
            }
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                vis[a[j]]=false;
            }
            la+=vec[i];
        }
        if(!ff) printf("-1\n");
        else {
            printf("%d\n",vec.size());
            for(int i=0;i<vec.size();i++) {
                printf("%d%c",vec[i],i==vec.size()-1?'\n':' ');
            }
        }
    }
    return 0;
}
/*6
2 1 -1 1 -2 -1
*/


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5,M=1e6+5;
int a[N],f[N],pos[M];
bool vis[M];
vector<int> vec;
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    bool ff=true;
    for(int i=1;i<=n;i++) {
        if(a[i]>0) {
            if(pos[a[i]]) ff=false;
            else pos[a[i]]=i;
        }
        else {
            if(!pos[-a[i]]) ff=false;
            else f[pos[-a[i]]]=i,pos[-a[i]]=0;
        }
    }
    if(!ff) printf("-1\n");
    else {
        for(int i=1,j;i<=n;) {
            if(a[i]<0) {
                i++;
                continue;
            }
            int t=f[i];
            for(j=i+1;j<=t;j++) {
                t=max(t,f[j]);
            }
            vec.push_back(j-i);
            i=j;
        }
        int la=1;
        for(int i=0;i<vec.size();i++) {
            int lb=la+vec[i]-1;
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                if(vis[a[j]]) ff=false;
                vis[a[j]]=true;
            }
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                vis[a[j]]=false;
            }
            la+=vec[i];
        }
        if(!ff) printf("-1\n");
        else {
            printf("%d\n",vec.size());
            for(int i=0;i<vec.size();i++) {
                printf("%d%c",vec[i],i==vec.size()-1?'\n':' ');
            }
        }
    }
    return 0;
}
/*6
2 1 -1 1 -2 -1
*/


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
int a[N],pos[N*10];
int f[N];
bool vis[N*10];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    bool ff=true;
    for(int i=1;i<=n;i++) {
        if(a[i]>0) {
            if(pos[a[i]]) ff=false;
            else pos[a[i]]=i;
        }
        else {
            if(!pos[-a[i]]) ff=false;
            else f[pos[-a[i]]]=i,pos[-a[i]]=0;
        }
    }
    if(!ff) printf("-1\n");
    else {
        vector<int> vec;
        for(int i=1,j;i<=n;) {
            int t=f[i];
            for(j=i;j<=t;j++) {
                t=max(t,f[j]);
            }
            vec.push_back(j-i);
            i=j;
        }
        int la=1;
        for(int i=0;i<vec.size();i++) {
            int lb=la+vec[i]-1;
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                if(vis[a[j]]) ff=false;
                vis[a[j]]=true;
            }
            for(int j=la;j<=lb;j++) {
                if(a[j]<0) continue;
                vis[a[j]]=false;
            }
            la+=vec[i];
        }
        if(!ff) printf("-1\n");
        else {
            printf("%d\n",vec.size());
            for(int i=0;i<vec.size();i++) {
                printf("%d%c",vec[i],i==vec.size()-1?'\n':' ');
            }
        }
    }
    return 0;
}
/*6
2 1 -1 1 -2 -1
*/


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   vector<int> vc(n), cnt(1000005), num(1000005), ans;
   int count=0;
   int len=0;
   int k=0;
   REP(i,n) cin>>vc[i];
   if (n==1) {
      cout<<-1<<endl;
      return 0;
   }
   REP(i,n){
      len++;
      if (vc[i]<0) {
         num[abs(vc[i])]+=1;
         cnt[abs(vc[i])]--;
         if (cnt[abs(vc[i])]<0) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==0) {
            count--;
         }
      }
      else {
         num[abs(vc[i])]+=2;
         cnt[abs(vc[i])]++;
         if (cnt[abs(vc[i])]>1) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==1) {
            count++;
         }
      }
      if (num[abs(vc[i])]>(3*(SZ(ans)+1))) {
         cout<<-1<<endl;
         return 0;
      }

      if (count==0){
         k++;
         ans.pb(len);
         len=0;
      }
   }
   cout<<k<<endl;
   REP(i,SZ(ans)) cout<<ans[i]<<' ';
   cout<<endl;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   vector<int> vc(n), cnt(1000005), num(1000005), ans;
   int count=0;
   int len=0;
   int k=0;
   REP(i,n) cin>>vc[i];
   REP(i,n){
      len++;
      if (vc[i]<0) {
         num[abs(vc[i])]+=1;
         cnt[abs(vc[i])]--;
         if (cnt[abs(vc[i])]<0) {
             cout<<i<<endl;
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==0) {
            count--;
         }
      }
      else {
         num[abs(vc[i])]+=2;
         cnt[abs(vc[i])]++;
         if (cnt[abs(vc[i])]>1) {
            cout<<i<<endl;
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==1) {
            count++;
         }
      }
      if (num[abs(vc[i])]>(3*(SZ(ans)+1))) {
         cout<<-1<<endl;
         return 0;
      }

      if (count==0){
         k++;
         ans.pb(len);
         len=0;
      }
   }
   cout<<k<<endl;
   REP(i,SZ(ans)) cout<<ans[i]<<' ';
   cout<<endl;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   vector<int> vc(n), cnt(1000005), num(1000005), ans;
   int count=0;
   int len=0;
   int k=0;
   REP(i,n) cin>>vc[i];
   REP(i,n){
      len++;
      if (vc[i]<0) {
         num[abs(vc[i])]+=1;
         cnt[abs(vc[i])]--;
         if (cnt[abs(vc[i])]<0) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==0) {
            count--;
         }
      }
      else {
         num[abs(vc[i])]+=2;
         cnt[abs(vc[i])]++;
         if (cnt[abs(vc[i])]>1) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==1) {
            count++;
         }
      }
      if (num[abs(vc[i])]>(3*(SZ(ans)+1))) {
         cout<<-1<<endl;
         return 0;
      }

      if (count==0){
         k++;
         ans.pb(len);
         len=0;
      }
   }
   cout<<k<<endl;
   REP(i,SZ(ans)) cout<<ans[i]<<' ';
   cout<<endl;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   vector<int> vc(n), cnt(1000005), num(1000005), ans;
   int count=0;
   int len=0;
   int k=0;
   REP(i,n) cin>>vc[i];
   REP(i,n){
      len++;
      if (vc[i]<0) {
         num[abs(vc[i])]+=1;
         cnt[abs(vc[i])]--;
         if (cnt[abs(vc[i])]<0) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==0) {
            count--;
         }
      }
      else {
         num[abs(vc[i])]+=2;
         cnt[abs(vc[i])]++;
         if (cnt[abs(vc[i])]>1) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==1) {
            count++;
         }
      }
      if (num[abs(vc[i])]>3) {
         cout<<-1<<endl;
         return 0;
      }

      if (count==0){
         k++;
         ans.pb(len);
         for (int j=i-1;j>=i-len;j--) num[abs(vc[j])]=0;
         len=0;
      }
   }
   if (count!=0) {
      cout<<-1<<endl;
      return 0;
   }
   cout<<k<<endl;
   REP(i,SZ(ans)) cout<<ans[i]<<' ';
   cout<<endl;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
   //ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   vector<int> vc(100005), cnt(1000005), num(1000005), ans;
   int count=0;
   int len=0;
   int k=0;
   REP(i,n) cin>>vc[i];
   REP(i,n){
      len++;
      if (vc[i]<0) {
         num[abs(vc[i])]+=1;
         cnt[abs(vc[i])]--;
         if (cnt[abs(vc[i])]<0) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==0) {
            count--;
         }
      }
      else {
         num[abs(vc[i])]+=2;
         cnt[abs(vc[i])]++;
         if (cnt[abs(vc[i])]>1) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==1) {
            count++;
         }
      }
      if (num[abs(vc[i])]>3) {
         cout<<-1<<endl;
         return 0;
      }

      if (count==0){
         k++;
         ans.pb(len);
         for (int j=i;j>=i-len+1;j--){
             if(vc[j] > 0)
                num[(vc[j])]=0;
         }
         len=0;
      }
   }
   if (count!=0) {
      cout<<-1<<endl;
      return 0;
   }
   cout<<k<<endl;
   REP(i,SZ(ans)) cout<<ans[i]<<' ';
   cout<<endl;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   vector<int> vc(n), cnt(1000005), num(n), ans;
   int count=0;
   int len=0;
   int k=0;
   REP(i,n) cin>>vc[i];
   REP(i,n){
      len++;
      if (vc[i]<0) {
         num[abs(vc[i])]+=1;
         cnt[abs(vc[i])]--;
         if (cnt[abs(vc[i])]<0) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==0) {
            count--;
         }
      }
      else {
         num[abs(vc[i])]+=2;
         cnt[abs(vc[i])]++;
         if (cnt[abs(vc[i])]>1) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==1) {
            count++;
         }
      }
      if (num[abs(vc[i])]>(3*(SZ(ans)+1))) {
         cout<<-1<<endl;
         return 0;
      }

      if (count==0){
         k++;
         ans.pb(len);
         len=0;
      }
   }
   cout<<k<<endl;
   REP(i,SZ(ans)) cout<<ans[i]<<' ';
   cout<<endl;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   vector<int> vc(n), cnt(1000005), num(1000005), ans;
   int count=0;
   int len=0;
   int k=0;
   REP(i,n) cin>>vc[i];
   REP(i,n){
      len++;
      if (vc[i]<0) {
         num[abs(vc[i])]+=1;
         cnt[abs(vc[i])]--;
         if (cnt[abs(vc[i])]<0) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==0) {
            count--;
         }
      }
      else {
         num[abs(vc[i])]+=2;
         cnt[abs(vc[i])]++;
         if (cnt[abs(vc[i])]>1) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==1) {
            count++;
         }
      }
      if (num[abs(vc[i])]>3) {
         cout<<-1<<endl;
         return 0;
      }

      if (count==0){
         k++;
         ans.pb(len);
         len=0;
      }
   }
   if (count!=0) {
      cout<<-1<<endl;
      return 0;
   }
   cout<<k<<endl;
   REP(i,SZ(ans)) cout<<ans[i]<<' ';
   cout<<endl;
   fill(ALL(num),0);
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   vector<int> vc(n), cnt(1000005), num(1000005), ans;
   int count=0;
   int len=0;
   int k=0;
   REP(i,n) cin>>vc[i];
   REP(i,n){
      len++;
      if (vc[i]<0) {
         num[abs(vc[i])]+=1;
         cnt[abs(vc[i])]--;
         if (cnt[abs(vc[i])]<0) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==0) {
            count--;
         }
      }
      else {
         num[abs(vc[i])]+=2;
         cnt[abs(vc[i])]++;
         if (cnt[abs(vc[i])]>1) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==1) {
            count++;
         }
      }
      if (num[abs(vc[i])]>(3*(SZ(ans)+1))) {
         cout<<-1<<endl;
         return 0;
      }

      if (count==0){
         k++;
         ans.pb(len);
         len=0;
      }
   }
   if (k==0) {
      cout<<-1<<endl;
      return 0;
   }
   cout<<k<<endl;
   REP(i,SZ(ans)) cout<<ans[i]<<' ';
   cout<<endl;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   vector<int> vc(n), cnt(1000005), num(1000005), ans;
   int count=0;
   int len=0;
   int k=0;
   REP(i,n) cin>>vc[i];
   REP(i,n){
      len++;
      if (vc[i]<0) {
         num[abs(vc[i])]+=1;
         cnt[abs(vc[i])]--;
         if (cnt[abs(vc[i])]<0) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==0) {
            count--;
         }
      }
      else {
         num[abs(vc[i])]+=2;
         cnt[abs(vc[i])]++;
         if (cnt[abs(vc[i])]>1) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==1) {
            count++;
         }
      }
      if (num[abs(vc[i])]>3) {
         cout<<-1<<endl;
         return 0;
      }

      if (count==0){
         k++;
         ans.pb(len);
         for (int j=i-1;j>=i-len;j--) num[abs(vc[i])]=0;
         len=0;
      }
   }
   if (count!=0) {
      cout<<-1<<endl;
      return 0;
   }
   cout<<k<<endl;
   REP(i,SZ(ans)) cout<<ans[i]<<' ';
   cout<<endl;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   vector<int> vc(n), cnt(1000005), num(1000005), ans;
   int count=0;
   int len=0;
   int k=0;
   REP(i,n) cin>>vc[i];
   REP(i,n){
      len++;
      if (vc[i]<0) {
         num[abs(vc[i])]+=1;
         cnt[abs(vc[i])]--;
         if (cnt[abs(vc[i])]<0) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==0) {
            count--;
         }
      }
      else {
         num[abs(vc[i])]+=2;
         cnt[abs(vc[i])]++;
         if (cnt[abs(vc[i])]>1) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==1) {
            count++;
         }
      }
      if (num[abs(vc[i])]>3) {
         cout<<-1<<endl;
         return 0;
      }

      if (count==0){
         k++;
         ans.pb(len);
         len=0;
         fill(ALL(num),0);
      }
   }
   if (count!=0) {
      cout<<-1<<endl;
      return 0;
   }
   cout<<k<<endl;
   REP(i,SZ(ans)) cout<<ans[i]<<' ';
   cout<<endl;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   vector<int> vc(n), cnt(1000005), num(1000005), ans;
   int count=0;
   int len=0;
   int k=0;
   REP(i,n) cin>>vc[i];
   REP(i,n){
      len++;
      if (vc[i]<0) {
         num[abs(vc[i])]+=1;
         cnt[abs(vc[i])]--;
         if (cnt[abs(vc[i])]<0) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==0) {
            count--;
         }
      }
      else {
         num[abs(vc[i])]+=2;
         cnt[abs(vc[i])]++;
         if (cnt[abs(vc[i])]>1) {
            cout<<-1<<endl;
            return 0;
         }
         if (cnt[abs(vc[i])]==1) {
            count++;
         }
      }
      if (num[abs(vc[i])]>(3*(SZ(ans)+1))) {
         cout<<-1<<endl;
         return 0;
      }

      if (count==0){
         k++;
         ans.pb(len);
         len=0;
      }
   }
   if (count!=0) {
      cout<<-1<<endl;
      return 0;
   }
   cout<<k<<endl;
   REP(i,SZ(ans)) cout<<ans[i]<<' ';
   cout<<endl;
}


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

    int main(){
        int n;
        cin>>n;
        int arr[n];
        vector <int> v;
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        int count=0;
        int c=0;
        int val=0;
        int i;
        map<int,int> m;
        for(i=0;i<n;i++){
          if(m[arr[i]]==0){
            m[arr[i]]++;
            val+=arr[i];
            if(val<0){
                cout<<-1<<endl;
                break;
            }
            else if(val==0){
                count++;
                v.push_back(count);
                count=0;
                c++;
            }
            else{
                count++;
            }
            }
            else{
                cout<<-1<<endl;
                break;
            }
        }
        if(i==n && val>0){
            cout<<-1<<endl;
        }
        else if(i==n && val==0){
            cout<<c<<endl;
            for(int i=0;i<v.size();i++){
                cout<<v[i]<<endl;
            }
        }

    }


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

    int main(){
        int n;
        cin>>n;
        int arr[n];
        vector <int> v;
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        int count=0;
        int c=0;
        int val=0;
        int i;
        for(i=0;i<n;i++){
            val+=arr[i];
            if(val<0){
                cout<<-1<<endl;
                break;
            }
            else if(val==0){
                count++;
                v.push_back(count);
                count=0;
                c++;
            }
            else{
                count++;
            }
        }
        if(i==n && val>0){
            cout<<-1<<endl;
        }
        else if(i==n && val==0){
            cout<<c<<endl;
            for(int i=0;i<v.size();i++){
                cout<<v[i]<<endl;
            }
        }

    }