Flymouse is a student of Computer School of Wuhan University. He loves surfing the Internet very much. But his bedroom is outside the campus. After long time thinking, he decides to apply the Internet service. But Flymouse is very poor. He wants to share the connection with his classmates. For the minimum cost, he must pave the shortest lines to connect every computer. Given a list of how much lines it takes to connect each pair of computer, you must find the minimum amount of lines needed to connect them all together. Each computer must connect to some other computers so that a packet can flow from any computer to any other computer. The distance between any two computers will not exceed 100,000.
The input includes several cases. The first line contains a single integer t (1 <= t <= 100), the number of test cases. For each case, the first line contains the number of computers, N (3 <= N <= 100). The following N lines contain the N x N matrix, where each element shows the distance from one computer to another. Logically, they are N lines of N space-separated integers. Of course, the diagonal will be 0, since the distance from computer i to itself is not interesting for this problem.
For each case, output a single integer that is the sum of the minimum length of lines required to connect the entire set of computers.
