cho.sh
Notes
Loading...

Hyungtaek's Candy Bags

Time limit

5s

Memory limit

128 MB

Problem

Hyungtaek has N candy bags. Bag i contains exactly i candies, for every 1 <= i <= N.

He wants to keep only some of the bags. The kept bags must satisfy this rule: if two different kept bags are combined, the total number of candies must not be equal to the number of candies in another kept bag.

Choose as many bags as possible under this rule. Your program must output the maximum number of bags K, the number of possible maximum choices A, and every maximum choice.

Input

The first line contains the number of test cases D. (1 <= D <= 100)

Each of the next D lines contains one integer N. (1 <= N <= 1,000,000)

Output

For each test case, first output one line containing two integers K and A: the maximum number of bags that can be chosen, and the number of maximum choices.

Then output A lines, one for each maximum choice. Each line must contain the chosen K integers in increasing order, separated by spaces. Print the choices in lexicographic order when each choice is viewed as a sequence of integers.