2061: Z‘s CoffeeTime Limit: 1 Sec Memory Limit: 128 Mb Submitted: 138 Solved: 48 SpecialJudge
Z is crazy about coffee. One day he bought three cups of coffee. The first cup has a capacity of A ml, the second has B ml and the third has C ml. At the beginning, only the first cup is full of coffee, that is, Z only has A ml coffee and the other cups is empty. Because the cup has no scale, one operation of pouring coffee only stop until either one cup is full or empty. Z can only choose two cups to do the pouring operation. For some reasons, Z wants to get exactly D ml of coffee, and also he is so lazy that want the number of operations as least as possible. So he ask you for help.
The first line is the case number T.
Each case has one line with four integers A B C D as mentioned above.
1 ≤ A, B, C ≤ 1000
1 ≤ D ≤ max(A, B, C)
1 ≤ T ≤ 100
If he can get the exactly milliliter of coffee as he want, then print the least number of operation in a line.
And print the initial capacity of the three cups and then print the result after each operation line by line.
The print order should be the first cup, the second cup and the third cup.
If there are more than one operation schema, any of them will be accepted.
If he cannot get the exactly milliliter of coffee as he want , print "-1" without quotation.
1 12 8 5 10
5 12 0 0 7 0 5 0 7 5 5 7 0 5 2 5 10 2 0