// Arup Guha
// 7/23/2025
// Solution to CPU Problem from UCF HS Contest
// Illustrates Kruskal's Algorithm

import java.util.*;

public class cpu_kruskals {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process cases.
		for (int loop=1; loop<=nC; loop++) {
		
			int n = stdin.nextInt();
			ArrayList<edge> edges = new ArrayList<edge>();
			
			// Build the graph.
			for (int i=0; i<n; i++) {
				
				for (int j=0; j<n; j++) {
					int w = stdin.nextInt();
					
					// This is so we skip adding duplicate edges.
					if (j<=i) continue;
					
					// If we get here i<j.
					edges.add(new edge(i, j, w));
				}
			}
			
			// Run Prim's.
			int res = kruskals(edges, n);
			
			// Ta da!
			System.out.println("Design "+loop+": "+res+" micrometers");
		}
	}
	
	// Run's Kruskal's on the graph stored in edges that has n vertices.
	public static int kruskals(ArrayList<edge> edges, int n) {
	
		int mst = 0, numE = 0;
		
		// Sort edges by edge weight.
		Collections.sort(edges);
		
		// Will keep track of cycle detection.
		djset dj = new djset(n);
		
		// Run until we complete it or there's no mst.
		for (int i=0; i<edges.size() && numE<n-1; i++) {
		
			// Get the next edge.
			edge cur = edges.get(i);
			
			// Try to merge together.
			boolean added = dj.union(cur.u, cur.v);
			
			// They were already together.
			if (!added) continue;
			
			// Update all variables to account for the new edge.
			mst += cur.w;
			numE++;
		}
		
		// Returns the weight of the mst or -1 if none edges.
		return numE == n-1 ? mst : -1;
	}
}

class edge implements Comparable<edge> {

	public int u;
	public int v;
	public int w;
	
	public edge(int myu, int myv, int myw) {
		u = myu;
		v = myv;
		w = myw;
	}	
	
	public int compareTo(edge other) {
		if (this.w != other.w) return this.w-other.w;
		if (this.u != other.u) return this.u - other.u;
		return this.v - other.v;
	}
}

class djset {

	public int[] par;
	
	public djset(int n) {
		par = new int[n];
		for (int i=0; i<n; i++)
			par[i] = i;
	}
	
	// Returns the root of the tree storing u (also does path compression)
	public int find(int u) {
		if (u == par[u]) return u;
		return par[u] = find(par[u]);
	}
	
	public boolean union(int u, int v) {
	
		// First find roots.
		u = find(u);
		v = find(v);
		
		// Already in the same set.
		if (u == v) return false;
		
		// Just attach v to u...
		par[v] = u;
		return true;
	}
}