P19551 [HackerEarth] Kattappa wants Baahubali to master mathematics. They decide to play the following turn-based game.
普及
题目描述

Kattappa wants Baahubali to master mathematics. They decide to play the following turn-based game.
They will be n x n grid M with random integers. Baahubali begins the game by crossing off an uncrossed row i of the grid. Now it's Kattappa turn and he crosses off an uncrossed column j of the grid. At the end of Kattappa's turn, Baahubali takes the number of candies in the i-th row and j-th column of M, call this value M (i, j), from Kattappa. (If M(i, j) is negative, then Baahubali gives M(i, j) candies to Kattappa.) The game continues alternating turns from Baahubali to Kattappa until the entire board is crossed off. Kattappa wants to know the maximum number of candies that Baahubali can win from him (or the minimum to lose if he cannot win) if both Baahubali and Kattappa play optimally. Help Baahubali find the solution.

Input:

First Line, number of test cases 1 ≤ t ≤ 20

Each test case starts with n (1 ≤ n ≤ 8), the size of the grid

Then follow n lines containing n numbers separated by spaces describing M. We call the j-th number on i-th line M (i, j) -1000 ≤ M(i,j) ≤ 1000

Output:

For each test case, print the maximum number of candies that Baahubali can win from Kattappa. If he cannot win, print the negative number indicating the minimum number of candies he loses.

SAMPLE INPUT
3
2
10 10
-5 -5
2
10 -5
10 -5
2
10 -5
-5 10

SAMPLE OUTPUT
5
5
-10

Explanation

Case 2:
Baahubali selects row 1 (answer doesn't change if row 2 is selected), Kattappa selects second column as -5 is minimum. So the current result is -5.
The only column and row left to be chosen is 10 i.e, second row first column. So the final result is -5 + 10 = 5.

输入格式

见题面

输出格式

见题面

样例输入
10 8 15 -51 -460 885 833 -522 520 825 781 -913 -382 445 -146 446 -210 -290 -802 175 -958 -776 859 -505 744 -879 -355 914 -495 52 -707 -739 855 -832 -752 -608 -757 189 60 683 -713 18 43 185 981 560 -425 294 18 316 -823 168 687 885 741 241 820 -902 572 -781 13 -929 -20 408 -38 -188 8 15 -51 -460 885 833 -522 520 825 781 -913 -382 445 -146 446 -210 -290 -802 175 -958 -776 859 -505 744 -879 -355 914 -495 52 -707 -739 855 -832 -752 -608 -757 189 60 683 -713 18 43 185 981 560 -425 294 18 316 -823 168 687 885 741 241 820 -902 572 -781 13 -929 -20 408 -38 -188 8 236 -364 129 131 -256 -783 -849 2 679 962 303 -914 205 -945 -850 141 932 -918 -675 118 537 418 -615 568 522 -15 -984 748 -180 496 960 806 833 -641 152 -128 40 -764 -656 638 240 383 -962 -483 -512 552 305 52 771 -335 -142 301 -700 -217 776 -914 579 620 -807 -62 -461 -479 972 594 8 547 -253 686 -22 980 -721 567 -681 32 -151 400 741 915 -942 520 -524 741 -779 558 727 -524 591 -634 -623 -441 -379 -505 247 -769 -650 -428 -354 330 -976 4 -805 839 -619 357 830 396 -18 17 -391 144 -73 594 121 631 191 488 -853 -391 -489 93 -926 216 461 899 710 273 996 -281 -171 8 547 -253 686 -22 980 -721 567 -681 32 -151 400 741 915 -942 520 -524 741 -779 558 727 -524 591 -634 -623 -441 -379 -505 247 -769 -650 -428 -354 330 -976 4 -805 839 -619 357 830 396 -18 17 -391 144 -73 594 121 631 191 488 -853 -391 -489 93 -926 216 461 899 710 273 996 -281 -171 8 -45 131 -517 775 -329 614 105 -567 -230 -598 -375 -259 557 -879 -462 280 28 -737 530 530 922 248 592 -954 79 -764 -900 -71 -624 -674 -780 592 745 733 -219 824 -96 858 267 -890 744 -182 57 479 584 766 486 552 757 -194 -237 -807 470 712 -857 774 -636 933 -900 373 -944 536 -566 39 8 -45 131 -517 775 -329 614 105 -567 -230 -598 -375 -259 557 -879 -462 280 28 -737 530 530 922 248 592 -954 79 -764 -900 -71 -624 -674 -780 592 745 733 -219 824 -96 858 267 -890 744 -182 57 479 584 766 486 552 757 -194 -237 -807 470 712 -857 774 -636 933 -900 373 -944 536 -566 39 8 488 787 29 546 -283 50 -504 -394 -618 -726 -263 -832 -836 832 219 473 706 -155 -796 827 -348 720 375 -337 -83 639 -724 286 330 -843 966 946 -956 -95 492 830 870 381 353 928 162 -855 -417 -135 329 -986 -985 655 722 -691 742 744 449 -546 -914 -620 -729 -652 304 583 -765 617 189 -379 8 -804 603 -17 -870 527 -117 496 970 -110 -612 -420 -526 915 -501 894 -487 -318 96 854 -922 688 902 120 -183 -411 -368 364 306 991 -394 -236 -962 40 270 404 -655 610 656 -117 650 324 740 -293 656 232 -548 0 -713 637 315 865 -823 -215 -895 -698 241 -943 -399 97 900 795 488 -336 526 8 -804 603 -17 -870 527 -117 496 970 -110 -612 -420 -526 915 -501 894 -487 -318 96 854 -922 688 902 120 -183 -411 -368 364 306 991 -394 -236 -962 40 270 404 -655 610 656 -117 650 324 740 -293 656 232 -548 0 -713 637 315 865 -823 -215 -895 -698 241 -943 -399 97 900 795 488 -336 526
样例输出
-1941 -4822 827 -255 -962 -613 -3447 -555 -4132 822