402859: GYM100923 C Por Costel and Bujor

Memory Limit:64 MB Time Limit:4 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Por Costel and Bujortime limit per test4 secondsmemory limit per test64 megabytesinputbujor.inoutputbujor.out

Bujor is really into gambling. He has casinos in his city, each of them having slot machines. In each day of the next days, he will visit each slot machine of each casino and will play a number of times. More formally, he has a matrix , where is the number of times in which he will play at the -th machine in the -th casino, each day.

The casinos all belong to the same firm, PCGE - Por Costel Gambling Enterprise. Por Costel has recently become a respected business pig. At the beginning of each day, the slot machines can be "manipulated". To be more specific, at the beginning of each day, Por Costel will send the same order to each casino, a list of numbers, which represent the expected-winnings with which to set each machine. The expected-winnings of a machine is the expected sum of money that one would win if he played at that machine once (it is real number, possibly even negative). The -th number on the list will represent the expected-winnings for the -th machine in every casino. More formally, Por Costel has matrix , where = expected-winnings for the -th machine in each casino, on the -th day.

The problem now is that Por Costel and Bujor are friends. Por Costel pities his friend and his gambling addiction. That's why he would like to be kind to him but without damaging his company's profits and without the other executives noticing. He wishes that each day, Bujor should achieve expected-winnings at exactly one casino, and expected-winnings at the rest. Lastly, there shouldn't be, after the days, a casino at which Bujor has not had expected-winnings of .

Knowing Bujor's matrix , you need to choose Por Costel's matrix such that the above conditions are met.

Input

The input file bujor.in will contain on its first line the integer (), the number of test cases.

Each of the tests will have the following format:

The first line will contain an integer (), the number of days, casinos and slot machines within each casino.

On each of the next lines, there will be integers. The -th number of the -th line represents the value ()

It is guaranteed that there exists at least one solution for any of the given test cases.

Output

The output file bujor.out should contain the answer for each of the test cases.

More precisely, a test case should contain lines each having space separated numbers. This should represent a possible option for Por Costel's matrix P.

may take any real value, but they should fit into double precision floating point format. You need not leave extra empty lines between the test cases.

It is guaranteed that there exists at least one solution for any of the given test cases.

If there are multiple solutions, print any of them.

It is recommended that you print floating point numbers with digits of precision.

ExampleInput
1
3
2 1 2
3 2 2
0 1 1
Output
0.333333333 -0.666666667 0.000000000 
0.666666667 0.666666667 -1.00000000
-0.666666667 0.333333333 1.000000000

加入题单

算法标签: