Pizza Slice Debt Settlement#1336

Pizza Slice Debt Settlement

1 second
64 megabytes
Very easy

Pizza Crisis in the Lair! Empty pizza boxes everywhere. Four turtles, zero slices left. Master Splinter looks at his students and says: "Perhaps it's time you learned to share pizza more wisely, my sons!"

Okay, so here's the situation. Leonardo, Michelangelo, Donatello, and Raphael have been trading pizza slices with each other all week, and now nobody remembers who owes what to whom. They all owe each other slices, but no turtle has enough slices on hand to pay everyone back, even though mathematically the numbers should work out.

Let me show you the pizza debt situation shown in figure (a). The graph displays how many slices are owed between the four turtles (Leo, Mikey, Donnie, and Raph). For example, Leo owes Mikey slices, while Mikey owes Leo slices. (Yeah, it happens - two turtles can owe each other at the same time!) To settle everything, they'd need pizza slices to pass around.

But wait! After studying this mess, I realized there's a smarter way. We're wasting pizza on unnecessary transfers! Check this out:

  1. Donnie owes Raph exactly slices, and Raph owes Leo the same slices. So why not skip the middleman? Donnie can pay Leo directly, and we eliminate Raph from the chain!

  2. But hold on - Leo already owes Donnie slices. So really, Leo only needs to pay Donnie the difference: slices.

  3. Same idea with Mikey and Leo. Mikey owes Leo slices, but Leo owes Mikey slices. Net result? Mikey pays Leo just slices. Now we're down to figure (b), and we only need slices total. That's slices saved, or %!

  4. But we can do even better! Instead of Mikey giving slices to Leo, and then Leo turning around and giving slices to Donnie, why not have Mikey give slices directly to Donnie? Then Mikey only gives slices to Leo. Check out figure (c) - we're down to just slices needed! That's a slice reduction, or %! Cowabunga!

I've got all the data about who owes whom, but I can't figure out the optimal way to minimize the pizza needed. Can you write a program that finds the minimum number of slices required to settle all the debts?

Input

Your program will be tested on one or more test cases. Each test case spans N+1 lines, where N < 1000 is the number of turtles (given on the first line). The next lines contain an N \times N matrix where entry shows how many slices turtle owes to turtle (the diagonal is all zeros since nobody owes themselves). Values are separated by spaces, and all numbers are less than . The input ends with a line containing a single .

Output

For each test case, output:

k. B A

where is the test case number (starting from ), is the total slices needed before optimization, and is the total slices needed after optimization.

Examples

Example 1

Loading
Loading