|
|||||||||||||||||||
|
SPOJ time: 2012-02-09 05:26:17 |
Nim-like game 2Problem code: HS09NLG2
It's time to help Julia to play with Robert again. This time the players pick up sticks from four stacks. A move consists of taking away a positive number of sticks from exactly two chosen stacks. Players take turns to move. The one who cannot make a move loses. Write a program which determines if for a given set of starting sizes of stacks Julia who moves first can force a win. If so help her making the winning move. If there are several possibilities of such a move, then choose the one which is lexicographically last, i.e. in which you use the stack with the smallest possible index, taking the largest number of sticks. InputIn the first line of input there is one integer C (1 ≤C ≤ 1 000), representing the number of test cases. Each test case is described by four integers a[1], a[2], a[3], a[4] (0<= a[i]<= 1 000 000), where a[i] denotes the number of sticks in the i-th stack. OutputFor each testcase write a sentence of the form: '$name wins.' as in the example. And if Julia can win write out four numbers two of which are nonzero - the numbers of sticks to take from each stack. Print a blank line after each testcase. ExampleInput: ScoringFor solving this problem you will score 10 points.
|
||||||||||||||||||
| |||||||||||||||||||