Problem hidden

TRANSFER - After Party Transfers

You've been to a potluck party (party where each person contributes food), but some people are angry that they spent more money preparing their dish than the others. Now they want you (they span the bottle) to figure out how the participants of the party can, in the fewest transfers, become even.

To clarify, you are free to transfer money between them in any way you like, but eventually the money they spent on their dishes, plus the money they received, minus the money the sent, must be equal for all participants.

Input

The first line contains C ∈ [0..10] - the number of test cases.

For each test case, the first line contains the number N ∈ [0..20] - the number of people at the party.

The following N lines contains a integer xi ∈ [0,106] representing the amount of money the ith person's dish cost.

Output

For each testcase:

The first line should be the minimal number of transfers needed to even out the party budget.

The following lines should be on the form "a -> b: t", where a, b ∈ [0..N) and represent that person 'a' must transfer 't' money to person 'b'. t is here a floating point number of at least 6 digits precision. (Notice: that is 6 digits precision after adding together your in and out flows)

In case of multiple best solutions exists, print any.

Example

Input:
2
6
2
4
1
5
0
6
3
9
16
25

Output:
3
0 -> 1: 1.0
2 -> 3: 2.0
4 -> 5: 3.0
2
0 -> 1: 7.6666666666667
1 -> 2: 8.33333333333

Explanation:

In the first case, 3 is the minimal amount of transfers. An alternative transfer pattern would be

"0 -> 3: 1    1 -> 3: 2    2 -> 4: 2     2 -> 5: 1". That would have made everyone even, but would have taken one more transfer (4).

In the second case, after the transfers, each person is down 16.666.


Adicionado por:Thomas Dybdahl Ahle
Data:2011-12-13
Tempo limite:1s-1.038s
Tamanho do fonte:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Linguagem permitida:Todas exceto: ASM64 CLOJURE ERL FSHARP PERL6 PY_NBC SCALA TCL
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.