/**
 * S. Behdad Hosseini, mailto:acm(AT)behdadh(DOT)net(replace AT and DOT), www.behdadh.net/acm
 * Date: Oct 27, 2005
 * A sample code for ACM problem : 2002 Asia Tehran - G
 */
#include <fstream.h>

#define FILEIN "g.in"
#define FILEOUT "g.out"

// calculates weight of a rank by formula: 2^(rank+1)-1
long weight(int rank)
{
	return (((long) 1) << (rank+1)) - 1;
}


void main()
{
	ifstream in(FILEIN);
	ofstream out(FILEOUT);

	int tc;
	in >> tc;
	for (;tc>0; tc--)
	{
		long n;
		int j=0, stack[100]; // stack: an array to reverse output numbers
		in >>n;
		out << n << " ["; 

		for (int i=0;weight(i)<=n;i++); // find the maximum number of digits in skew system (i)

		for (;i>=0;i--) // for all digits (ranks)
			if (2*weight(i) == n)
			{
				stack[j++] = i; // store current rank twice at top of stack
				stack[j++] = i;
				n -= 2*weight(i); // means n = 0
			}
			else if ( weight(i) <= n )
			{
				stack[j++] = i; // store current rank once at top of stack
				n -= weight(i); 
			}

		for (j=j-1;j>=0;j--) // pop all of the stack and write to output
		{
			out << stack[j];
			if (j!=0) out << ",";
		}

		out << "]" << endl;
	}

	in.close();
	out.close();
}




