Mancala

No attempts yetTime limit1sMemory limit256 MB

Problem

Mancala is a family of board games with many rule variants. This problem uses the simplest one, the one player game Tchoukaillon.

Tchoukaillon is played on a board whose pits sit in a single row. The leftmost pit is the Roumba, and the Roumba starts empty. The pits to the right of the Roumba are numbered 1, 2, 3, ... from left to right, and bkb_k is the number of marbles in pit kk.

One turn goes in this order.

  1. Find a pit kk with bk=kb_k = k. If several pits qualify, you can pick any of them.
  2. Empty that pit and hand out its kk marbles one at a time to the Roumba and to pits 1 through k1k - 1.

If marbles remain on the board and no pit satisfies bk=kb_k = k, the position is lost. The first row of the figure above shows pit 3 being chosen.

If repeated turns move every marble into the Roumba, the position is won, and a starting position that can be played to that end is a winning board. Once the total number of marbles NN is fixed, the winning board is always unique. For 4 marbles the only winning board is b1=0b_1 = 0, b2=1b_2 = 1, b3=3b_3 = 3.

Given the total number of marbles NN, find the winning board.

Input

The first line holds the number of test cases PP. (1P10001 \le P \le 1000)

Each of the next PP lines holds one test case: the case number TT and the total number of marbles NN placed on the board, separated by a space. (1TP1 \le T \le P, 1N21171 \le N \le 2117)

The bound 2117 is the largest NN whose winning board reaches no farther than pit 80.

Output

For each test case, print on one line the case number TT and the number BB of the rightmost pit that holds at least one marble.

Starting on the next line, print b1b_1 through bBb_B of the winning board in order, ten numbers per line separated by single spaces, with only the remaining numbers on the last line.

BB never exceeds 80 in any test case.